Small Update:
The same control PropertyGridEditorDoubleUpDown behaves differently when used outside of the data template and outside of it. (See sample code, try it with german language settings)
Sample xaml:
The same control PropertyGridEditorDoubleUpDown behaves differently when used outside of the data template and outside of it. (See sample code, try it with german language settings)
-
Outside of the control I used this (bound to the same model)
<tk:PropertyGridEditorDoubleUpDown Text="{Binding Blubber.ValidationDouble, UpdateSourceTrigger=PropertyChanged, ValidatesOnExceptions=True}"></tk:PropertyGridEditorDoubleUpDown>
- Immediate Validation working
-
the source property is updated correctly with the correclty converted double value.
-
Inside the dataTemplate the binding to the properties are done by the grid. I use the data template
<tk:PropertyGridEditorDoubleUpDown Text="{Binding Value, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}" >
</tk:PropertyGridEditorDoubleUpDown>
-
Property is not correclty updated, value converted with other culture settings, ignoring the currentculture.
Sample xaml:
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:lcl="clr-namespace:WpfApplication1"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:tk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:s="clr-namespace:System;assembly=mscorlib"
Title="MainWindow" Height="350" Width="525"
>
<Window.Resources>
<lcl:Converter x:Key="myConv" />
<Style TargetType="{x:Type Control}">
<Style.Triggers>
<Trigger Property="Validation.HasError" Value="true">
<Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}"/>
</Trigger>
</Style.Triggers>
</Style>
<Style TargetType="{x:Type tk:PropertyGridEditorDoubleUpDown}">
<Style.Triggers>
<Trigger Property="Validation.HasError" Value="true">
<Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}"/>
</Trigger>
</Style.Triggers>
</Style>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="20"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<tk:PropertyGridEditorDoubleUpDown Text="{Binding Blubber.ValidationDouble, UpdateSourceTrigger=PropertyChanged, ValidatesOnExceptions=True}"></tk:PropertyGridEditorDoubleUpDown>
<tk:PropertyGrid Grid.Row="1 " Margin="5" IsEnabled="True" ScrollViewer.VerticalScrollBarVisibility="Visible" Name="propertyGrid"
MinWidth="400" UpdateTextBoxSourceOnEnterKey="True" HorizontalContentAlignment="Left" NameColumnWidth="250" ClipToBounds="False"
VerticalContentAlignment="Stretch" Height="Auto" MaxHeight="800" DockPanel.Dock="Top" ShowSearchBox="False" ShowSortOptions="False" ShowSummary="False" ShowTitle="False"
SelectedObject="{Binding Blubber, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}" ShowAdvancedOptions="False" IsCategorized="True" AutoGenerateProperties="True">
<tk:PropertyGrid.EditorDefinitions>
<tk:EditorTemplateDefinition >
<tk:EditorTemplateDefinition.TargetProperties>
<tk:TargetPropertyType Type="{x:Type s:String}" />
</tk:EditorTemplateDefinition.TargetProperties>
<tk:EditorTemplateDefinition.EditingTemplate>
<DataTemplate>
<tk:PropertyGridEditorTextBox TextAlignment="Left" Text="{Binding Value, UpdateSourceTrigger=PropertyChanged}" />
</DataTemplate>
</tk:EditorTemplateDefinition.EditingTemplate>
</tk:EditorTemplateDefinition>
<tk:EditorTemplateDefinition >
<tk:EditorTemplateDefinition.TargetProperties>
<tk:TargetPropertyType Type="{x:Type s:Int32}" />
<tk:TargetPropertyType Type="{x:Type s:Int16}" />
<tk:TargetPropertyType Type="{x:Type s:Int64}" />
</tk:EditorTemplateDefinition.TargetProperties>
<tk:EditorTemplateDefinition.EditingTemplate>
<DataTemplate>
<tk:PropertyGridEditorIntegerUpDown TextAlignment="Left" Text="{Binding Value, UpdateSourceTrigger=PropertyChanged}" />
</DataTemplate>
</tk:EditorTemplateDefinition.EditingTemplate>
</tk:EditorTemplateDefinition>
<tk:EditorTemplateDefinition >
<tk:EditorTemplateDefinition.TargetProperties>
<tk:TargetPropertyType Type="{x:Type s:Single}" />
</tk:EditorTemplateDefinition.TargetProperties>
<tk:EditorTemplateDefinition.EditingTemplate>
<DataTemplate>
<tk:SingleUpDown Text="{Binding Value, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}" />
</DataTemplate>
</tk:EditorTemplateDefinition.EditingTemplate>
</tk:EditorTemplateDefinition>
<tk:EditorTemplateDefinition >
<tk:EditorTemplateDefinition.TargetProperties>
<tk:TargetPropertyType Type="{x:Type s:Double}" />
</tk:EditorTemplateDefinition.TargetProperties>
<tk:EditorTemplateDefinition.EditingTemplate>
<DataTemplate>
<tk:PropertyGridEditorDoubleUpDown Text="{Binding Value, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}" >
</tk:PropertyGridEditorDoubleUpDown>
</DataTemplate>
</tk:EditorTemplateDefinition.EditingTemplate>
</tk:EditorTemplateDefinition>
</tk:PropertyGrid.EditorDefinitions>
</tk:PropertyGrid>
</Grid>
</Window>