Hello,
I try to change the DataTemplate for the DataErrorContentTemplateKey. The only thing I need to do is to change the border color to red.
I think I miss where I have assign it to the DataGrid. Reshaper also tells me, that the template is never used. Can someone help me?oizControls:OizDataGrid is just a wrapper for XamDataGrid.
<UserControl.Resources> <ResourceDictionary> <Converters:DictionaryCodeTableConverter x:Key="DictionaryCodeTableConverter" /> <DataTemplate x:Key="{x:Static igDP:DataPresenterBase.DataErrorContentTemplateKey}" > <Border x:Name="Bd"> <DockPanel x:Name="panel"> <igWindows:AutomationControl x:Name="errorIcon" DockPanel.Dock="Left" Visibility="Collapsed" Margin="2,0" Style="{DynamicResource {x:Static igDP:DataPresenterBase.DataErrorIconStyleKey}}" /> <ContentPresenter ContentTemplate="{x:Null}" DataContext="{Binding Path=Content.Host.DataContext, RelativeSource={x:Static RelativeSource.Self}}" /> </DockPanel> </Border> <DataTemplate.Triggers> <MultiDataTrigger> <MultiDataTrigger.Conditions> <Condition Binding="{Binding Path=Host.HasDataError}" Value="true" /> <Condition Binding="{Binding Path=Host.IsDataErrorDisplayModeIcon}" Value="true" /> </MultiDataTrigger.Conditions> <Setter TargetName="errorIcon" Property="Visibility" Value="Visible" /> <Setter TargetName="errorIcon" Property="ToolTip" Value="{Binding Path=Host.DataError}" /> </MultiDataTrigger> <MultiDataTrigger> <MultiDataTrigger.Conditions> <Condition Binding="{Binding Path=Host.HasDataError}" Value="true" /> <Condition Binding="{Binding Path=Host.IsDataErrorDisplayModeHighlight}" Value="true" /> </MultiDataTrigger.Conditions> <Setter TargetName="Bd" Property="Background" Value="{DynamicResource {x:Static igDP:DataPresenterBrushKeys.DataErrorHighlightBackgroundBrushKey}}" /> <Setter TargetName="Bd" Property="BorderBrush" Value="Red" /> <Setter TargetName="Bd" Property="BorderThickness" Value="1"/> <Setter TargetName="Bd" Property="CornerRadius" Value="1"/> <Setter TargetName="panel" Property="ToolTip" Value="{Binding Path=Host.DataError}" /> </MultiDataTrigger> </DataTemplate.Triggers> </DataTemplate>
</ResourceDictionary> </UserControl.Resources> <oizControls:OizDataGrid DataSource="{Binding Path=Relations}" IsSynchronizedWithCurrentItem="True" IsNestedDataDisplayEnabled="False" IsExcelExportEnabled="False" IsWordExportEnabled="False" IsGroupByAreaExpanded="False" GroupByAreaLocation="None" EditModeEnded="OizDataGridEditModeEnded" RecordUpdating="OizDataGridRecordUpdating"> <oizControls:OizDataGrid.Resources> <Style x:Key="PersonEditButtonTemplate" TargetType="{x:Type igDP:CellValuePresenter}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}"> <oizControls:OizButtonTool SmallImage="..\..\Resources\16x16\edit.png" Command="{Binding Path=DataContext.RelationEditCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type oizControls:OizDataGrid}}}" CommandParameter="{Binding DataItem.PRS_ID}"/> </ControlTemplate> </Setter.Value> </Setter> </Style> <Style TargetType="{x:Type igDP:CellValuePresenter}" x:Key="hyperlinkCell"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}"> <oizControls:OizLinkButton Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Value}" HandeLinkAs="Email" NavigateUri="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Value}" IsAutoOpenUrlEnabled="True"/> </ControlTemplate> </Setter.Value> </Setter> </Style> </oizControls:OizDataGrid.Resources> <oizControls:OizDataGrid.FieldLayouts> <igDP:FieldLayout> <igDP:FieldLayout.Fields> <igDP:UnboundField Name="EditPerson" Label="Bearb." Width="Auto"> <igDP:UnboundField.Settings> <igDP:FieldSettings CellValuePresenterStyle="{StaticResource PersonEditButtonTemplate}" CellHeight="22" CellWidth="22"/> </igDP:UnboundField.Settings> </igDP:UnboundField> <igDP:Field Name="PRS_ID" Label="Name" Width="Auto"> <igDP:Field.Settings> <igDP:FieldSettings EditorType="{x:Type igEditors:XamComboEditor}" AllowEdit ="True"> <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamComboEditor}"> <Setter Property="ItemsSource" Value="{Binding Path=DataContext.DropDownListElements, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type oizControls:OizDataGrid}}}" /> <Setter Property="DisplayMemberPath" Value="PRS_OutlookName" /> <Setter Property="ValuePath" Value="PRS_ID" /> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:Field.Settings> </igDP:Field> <igDP:UnboundField Name="PRS_Alias" BindingPath="PRS_Person.PRS_Alias" Label="Kürzel" Width="*"/> <igDP:Field Name="CTI_BetriebsRolleCode_ID" Label="Name" Width="*"> <igDP:Field.Settings> <igDP:FieldSettings EditorType="{x:Type igEditors:XamComboEditor}" AllowEdit ="True"> <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamComboEditor}"> <Setter Property="ItemsSource" Value="{Binding Path=DataContext.CodeTables, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type oizControls:OizDataGrid}}, Converter={StaticResource DictionaryCodeTableConverter}, ConverterParameter=RzMoveBetriebsRolle}" /> <Setter Property="DisplayMemberPath" Value="CTIKurzBez" /> <Setter Property="ValuePath" Value="CTIID" /> <Setter Property="Value" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Value, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}"/> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:Field.Settings> </igDP:Field> <igDP:UnboundField Name="PRS_Email" BindingPath="PRS_Person.PRS_Email" Label="E-Mail" Width="Auto"> <igDP:Field.Settings> <igDP:FieldSettings CellValuePresenterStyle="{StaticResource hyperlinkCell}"/> </igDP:Field.Settings> </igDP:UnboundField> <igDP:UnboundField Name="PRS_Festnetz" BindingPath="PRS_Person.PRS_Festnetz" Label="Telefon (Festnetz)" Width="*"/> <igDP:UnboundField Name="PRS_Handy" BindingPath="PRS_Person.PRS_Handy" Label="Telefon (Mobil)" Width="*"/> </igDP:FieldLayout.Fields> </igDP:FieldLayout> </oizControls:OizDataGrid.FieldLayouts> <oizControls:OizDataGrid.FieldLayoutSettings> <igDP:FieldLayoutSettings AutoGenerateFields="False" AllowAddNew="False" AllowDelete="False" SelectionTypeRecord="Single" SelectionTypeField="None" SelectionTypeCell="None" AutoFitMode="OnlyWithVisibleStarFields" SupportDataErrorInfo="CellsOnly" DataErrorDisplayMode="ErrorIconAndHighlight" /> </oizControls:OizDataGrid.FieldLayoutSettings> <oizControls:OizDataGrid.FieldSettings> <igDP:FieldSettings AllowEdit="False" AllowRecordFiltering="False" /> </oizControls:OizDataGrid.FieldSettings> </oizControls:OizDataGrid>
<oizControls:OizDataGrid DataSource="{Binding Path=Relations}" IsSynchronizedWithCurrentItem="True" IsNestedDataDisplayEnabled="False" IsExcelExportEnabled="False" IsWordExportEnabled="False" IsGroupByAreaExpanded="False" GroupByAreaLocation="None" EditModeEnded="OizDataGridEditModeEnded" RecordUpdating="OizDataGridRecordUpdating"> <oizControls:OizDataGrid.Resources> <Style x:Key="PersonEditButtonTemplate" TargetType="{x:Type igDP:CellValuePresenter}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}"> <oizControls:OizButtonTool SmallImage="..\..\Resources\16x16\edit.png" Command="{Binding Path=DataContext.RelationEditCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type oizControls:OizDataGrid}}}" CommandParameter="{Binding DataItem.PRS_ID}"/> </ControlTemplate> </Setter.Value> </Setter> </Style> <Style TargetType="{x:Type igDP:CellValuePresenter}" x:Key="hyperlinkCell"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}"> <oizControls:OizLinkButton Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Value}" HandeLinkAs="Email" NavigateUri="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Value}" IsAutoOpenUrlEnabled="True"/> </ControlTemplate> </Setter.Value> </Setter> </Style> </oizControls:OizDataGrid.Resources> <oizControls:OizDataGrid.FieldLayouts> <igDP:FieldLayout> <igDP:FieldLayout.Fields> <igDP:UnboundField Name="EditPerson" Label="Bearb." Width="Auto"> <igDP:UnboundField.Settings> <igDP:FieldSettings CellValuePresenterStyle="{StaticResource PersonEditButtonTemplate}" CellHeight="22" CellWidth="22"/> </igDP:UnboundField.Settings> </igDP:UnboundField> <igDP:Field Name="PRS_ID" Label="Name" Width="Auto"> <igDP:Field.Settings> <igDP:FieldSettings EditorType="{x:Type igEditors:XamComboEditor}" AllowEdit ="True"> <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamComboEditor}"> <Setter Property="ItemsSource" Value="{Binding Path=DataContext.DropDownListElements, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type oizControls:OizDataGrid}}}" /> <Setter Property="DisplayMemberPath" Value="PRS_OutlookName" /> <Setter Property="ValuePath" Value="PRS_ID" /> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:Field.Settings> </igDP:Field> <igDP:UnboundField Name="PRS_Alias" BindingPath="PRS_Person.PRS_Alias" Label="Kürzel" Width="*"/> <igDP:Field Name="CTI_BetriebsRolleCode_ID" Label="Name" Width="*"> <igDP:Field.Settings> <igDP:FieldSettings EditorType="{x:Type igEditors:XamComboEditor}" AllowEdit ="True"> <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamComboEditor}"> <Setter Property="ItemsSource" Value="{Binding Path=DataContext.CodeTables, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type oizControls:OizDataGrid}}, Converter={StaticResource DictionaryCodeTableConverter}, ConverterParameter=RzMoveBetriebsRolle}" /> <Setter Property="DisplayMemberPath" Value="CTIKurzBez" /> <Setter Property="ValuePath" Value="CTIID" /> <Setter Property="Value" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Value, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}"/> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:Field.Settings> </igDP:Field> <igDP:UnboundField Name="PRS_Email" BindingPath="PRS_Person.PRS_Email" Label="E-Mail" Width="Auto"> <igDP:Field.Settings> <igDP:FieldSettings CellValuePresenterStyle="{StaticResource hyperlinkCell}"/> </igDP:Field.Settings> </igDP:UnboundField> <igDP:UnboundField Name="PRS_Festnetz" BindingPath="PRS_Person.PRS_Festnetz" Label="Telefon (Festnetz)" Width="*"/> <igDP:UnboundField Name="PRS_Handy" BindingPath="PRS_Person.PRS_Handy" Label="Telefon (Mobil)" Width="*"/> </igDP:FieldLayout.Fields> </igDP:FieldLayout> </oizControls:OizDataGrid.FieldLayouts> <oizControls:OizDataGrid.FieldLayoutSettings> <igDP:FieldLayoutSettings AutoGenerateFields="False" AllowAddNew="False" AllowDelete="False" SelectionTypeRecord="Single" SelectionTypeField="None" SelectionTypeCell="None" AutoFitMode="OnlyWithVisibleStarFields" SupportDataErrorInfo="CellsOnly" DataErrorDisplayMode="ErrorIconAndHighlight" /> </oizControls:OizDataGrid.FieldLayoutSettings> <oizControls:OizDataGrid.FieldSettings> <igDP:FieldSettings AllowEdit="False" AllowRecordFiltering="False" /> </oizControls:OizDataGrid.FieldSettings> </oizControls:OizDataGrid>
Hello Mario,
I am just checking if you got this worked out or you still require any assistance or clarification on the matter.
Hi I have similar issue,
1) I can see that IDataErrorInfo.["field"] is called for all the fields in the DataSource for the first time after RecoredAdded to the source, after that I see that IDataErrorInfo .. is called only for the last column.
2) The error high lighting works for Field and doesn't work for UnBoundFields.
Could you send some example where IDataError Stuff works for both Field and UnBoundField, where UnBoundField's editor is changed programmatic way and values are also set in code behind. Thanks
Hello Dhanasekaran,
I have logged this with development under ID: 124474 and I have also created a support ticket on your behalf: CAS-102971-P0S0J3 and have linked the development issue to it, so that you can get automatically updated, when a Service Release containing the fix is available for download. You can get the new version from our website’s “My IG”, “My Keys & Downloads” tags: https://es.infragistics.com/Membership/Default.aspx?panel=Downloads#Downloads
You can also monitor the support ticket’s progress through the “My Support Activity” tag: https://es.infragistics.com/Membership/MySupport.aspx