Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
35
Define custom DataErrorContentTemplateKey
posted

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>