Hello,
I have one problem with bindings in NumericUpDown editor. Code first:
Xaml:
<UserControl x:Class="SilverlightApplication.MainPage"
xmlns:telerik_pres="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input" >
<Grid x:Name="LayoutRoot" Background="White">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
</Grid.ColumnDefinitions>
<StackPanel x:Name="SpDecimal" Grid.Row="0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Text="Default value" />
<telerik_pres:RadNumericUpDown x:Name="DpDecimal"
Value="{Binding Path=DefaultValue, Mode=TwoWay}"
NumberDecimalDigits="{Binding ElementName=RnudDecimalScale, Path=Value}"
Minimum="{Binding ElementName=RnudDecimalMin, Path=Value}"
Maximum="{Binding ElementName=RnudDecimalMax, Path=Value}"
Grid.Row="0" Grid.Column="1" />
</Grid>
</StackPanel>
<StackPanel x:Name="SpDecimalProp" Grid.Row="1">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Text="Precision" />
<telerik_pres:RadNumericUpDown x:Name="RnudDecimalPrecision" Value="{Binding Path=Precision, Mode=TwoWay}" Grid.Row="0" Grid.Column="1" NumberDecimalDigits="0"/>
<TextBlock Grid.Row="1" Grid.Column="0" Text="Scale" />
<telerik_pres:RadNumericUpDown x:Name="RnudDecimalScale" Value="{Binding Path=Scale, Mode=TwoWay}" Grid.Row="1" Grid.Column="1" NumberDecimalDigits="0"/>
<TextBlock Grid.Row="2" Grid.Column="0" Text="Min" />
<telerik_pres:RadNumericUpDown x:Name="RnudDecimalMin" Value="{Binding Path=Min, Mode=TwoWay}" Grid.Row="2" Grid.Column="1" NumberDecimalDigits="0"/>
<TextBlock Grid.Row="3" Grid.Column="0" Text="Max" />
<telerik_pres:RadNumericUpDown x:Name="RnudDecimalMax" Value="{Binding Path=Max, Mode=TwoWay}" Grid.Row="3" Grid.Column="1" NumberDecimalDigits="0"/>
</Grid>
</StackPanel>
<StackPanel Grid.Row="2" >
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Button Content="Test" Click="Button_Click" Grid.Row="0" Grid.Column="0"/>
<TextBlock Text="Entity value" Grid.Row="0" Grid.Column="1"/>
<TextBox x:Name="TxbResult" Text="empty" Grid.Row="0" Grid.Column="1"/>
</Grid>
</StackPanel>
</Grid>
</UserControl>
Code behind:
Entity.cs:
I'm trying to bind control
DpDecimal to DefaultValue of an entity. I have also some properties of the default value like precision, scale,..
The control
DpDecimal has bound its properties
NumberDecimalDigits, Minimum, Maximum to controls of these properties. I have also one help button here and when click to this button the actual value of entity default value is filled into the textbox next to it, just for testing.
I'm trying this scenario:
1. fill min = 1, max = 1000, scale = 2, precision = 5 and default value = 500
2. change min value to 600 and click the button test before losing focus. This works and default value is changed in control and also in entity property to min value = 600.
3. change default value to 600,19
4. change scale to 1 and click the test button before losing focus. Now the value in control is changed correctly to 600,2 but the value in the entity is still 600,19, what you can see in the result textbox next to the button.
I need somehow to fix this to have changed also the value of the property in the entity. I also need to keep default value as a string because of the structure of my application. I did try to handle events from property controls and update the control of default value source explicitly but it also doesn't work. Neither change of UpdateEvent to PropertyChanged help.
Thanks for any advice.