I have a column which has read mode or edit mode. Read mode means that column display text in a textblock. Edit mode means that the column display a textbox or combobox so the use can input the value in the control. So I want to customize the datetemplate.
<telerik:GridViewDataColumn DataMemberBinding="{Binding Salary}"> <telerik:GridViewDataColumn.CellTemplate> <DataTemplate> <StackPanel> <TextBlock Text="{Binding Salary}" Visibility="{Binding ReadOrEdit, Convert={StackResources BooleanToOpacityConverter}}" Validation.ErrorTemplate="{StackResources myTemplate}"/> <TextBox Text="{Binding Salary}" Visibility="{Binding ReadOrEdit, Convert={StackResources InvertedBooleanToVisibilityConverter}}" Validation.ErrorTemplate="{StackResources myTemplate}"/> </StackPanel> </DataTemplate> </telerik:GridViewDataColumn.CellTemplate> </telerik:GridViewDataColumn>The validation template likes
<ControlTemplate x:Key="myTemplate"> <DockPanel> <Border BorderBrush="Red" BorderThickness="1"> <AdornedElementPlaceholder x:Name="controlWithError"/> </Border> <TextBlock Foreground="Red" FontSize="20" FontFamily="Segoe UI" Margin="3,0,0,0" MouseDown="Exclamation_MouseDown" Tag="{Binding AdornedElement.(Validation.Errors)[0].ErrorContent, ElementName=controlWithError}">!</TextBlock> </DockPanel></ControlTemplate>I am not sure it is the right way. Should I put the textbox in CellEditingTemplate because of it is for editing? The reason is when we validate the textbox I found besides the textbox also inside the textbox there was a red border around the text. It means there are two adorners.
Thanks