Hi,
I need to display two properties of my viewmodel under the same column, so I've come up with the below field settings.
<igDP:Field Name="CountryCode" Label="Country Code" Width="Auto"> <igDP:Field.Settings> <igDP:FieldSettings> <igDP:FieldSettings.CellValuePresenterStyle> <Style TargetType="{x:Type igDP:CellValuePresenter}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate> <Controls:BrokerFeeRuleConditionView ConditionValue="{Binding DataItem.CountryCode}" ConditionOp="{Binding DataItem.CountryCodeOperator}"/> </ControlTemplate> </Setter.Value> </Setter> </Style> </igDP:FieldSettings.CellValuePresenterStyle> </igDP:FieldSettings> </igDP:Field.Settings> </igDP:Field>
And this is the XAML of BrokerFeeRuleConditionView:
<Grid > <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/> </Grid.ColumnDefinitions> <Editors:XamComboEditor MinWidth="120" Grid.Column="0" ItemsProvider="{StaticResource BrokeerFeeRuleOperationTypesProvider}" SelectedItem="{Binding ElementName=This,Path=ConditionOp}" DisplayMemberPath="Value" ValuePath="Key" /> <Editors:XamTextEditor Grid.Column="1" MinWidth="120" Text="{Binding ElementName=This,Path=ConditionValue, Mode=TwoWay}" /> </Grid>
Both ConditionOp and ConditionValue are dependency properties declared by BrokerFeeRuleConditionView.
My problem is that even though the bindings are correctly set up and my validation rules kick in (double-checked by stepping through the code), I don't get to see my error tooltip.
On the other hand, if I just use a simple field settings such as <igDP:Field Name="Counterparty" Label="Counterparty" Width="Auto"/> then the tooltip comes up.
And below is the template we're using for the tooltip:
<DataTemplate x:Key="{x:Static igDP:DataPresenterBase.DataErrorContentTemplateKey}"> <Grid x:Name="panel"> <Grid.ToolTip> <ToolTip x:Name="toolTip" Content="{Binding Host.DataError, Converter={StaticResource _validationValueConverter}}"/> </Grid.ToolTip> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <ContentPresenter x:Name="content" DataContext="{Binding Host.Record}" ContentTemplate="{x:Null}" /> <Path x:Name="errorBorder" Grid.Row="1" Grid.Column="1" Stretch="Fill" RenderTransformOrigin="0.5,0.5" StrokeThickness="1" HorizontalAlignment="Right" VerticalAlignment="Bottom" Width="6" Height="6" Data="M60,60L60,40 70,40z" Visibility="Visible" Opacity="0.75"> <Path.RenderTransform> <RotateTransform CenterX="0" CenterY="0" Angle="180" /> </Path.RenderTransform> </Path> </Grid> <DataTemplate.Triggers> <MultiDataTrigger> <MultiDataTrigger.Conditions> <Condition Binding="{Binding Path=Host.HasDataError}" Value="true" /> <Condition Binding="{Binding Path=Host.DataError, Converter={StaticResource _validationWarningValueConverter}}" Value="true" /> </MultiDataTrigger.Conditions> <Setter TargetName="errorBorder" Property="Fill" Value="#FF0000FF" /> <Setter TargetName="errorBorder" Property="Stroke" Value="#FF0000FF" /> <Setter TargetName="errorBorder" Property="Visibility" Value="Visible" /> <Setter TargetName="errorBorder" Property="Opacity" Value="0.9" /> <Setter TargetName="toolTip" Property="Style" Value="{StaticResource _warningTooltipStyle}" /> </MultiDataTrigger> <MultiDataTrigger> <MultiDataTrigger.Conditions> <Condition Binding="{Binding Path=Host.HasDataError}" Value="true" /> <Condition Binding="{Binding Path=Host.DataError, Converter={StaticResource _validationWarningValueConverter}}" Value="false" /> </MultiDataTrigger.Conditions> <Setter TargetName="errorBorder" Property="Fill" Value="#FFFF0000" /> <Setter TargetName="errorBorder" Property="Stroke" Value="#FFFF0000" /> <Setter TargetName="errorBorder" Property="Visibility" Value="Visible" /> <Setter TargetName="toolTip" Property="Style" Value="{StaticResource _errorTooltipStyle}" /> </MultiDataTrigger> </DataTemplate.Triggers> </DataTemplate>
When using snoop we can see that the CellValuePresenter's HasDataError and DataError properties have the correct values.
Any ideas?
Many thanks.
Hello,
There are some missing pices of information in your codes that prevents us from putting together a sample and recreate the same behave you have. Can you please attach a sample so we can test and debug it?
Thank you,Sam
Let me check with engineering. I'll post back here with there suggestions.
BTW, please find below my custom control XAML:
<UserControl x:Class="MorganStanley.OTCLCM.TX.ReferenceData.Controls.BrokerFeeRuleConditionView" x:Name="This" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:Editors="clr-namespace:Infragistics.Windows.Editors;assembly=InfragisticsWPF3.Editors.v10.3" xmlns:System="clr-namespace:System;assembly=mscorlib" xmlns:Controls1="clr-namespace:MorganStanley.OTCLCM.TX.ReferenceData.Controls" xmlns:ViewModels1="clr-namespace:MorganStanley.OTCLCM.TX.ReferenceData.ViewModels" xmlns:DataPresenter="clr-namespace:Infragistics.Windows.DataPresenter;assembly=InfragisticsWPF3.DataPresenter.v10.3" xmlns:BrokerFeeRules="clr-namespace:MorganStanley.OTCLCM.TX.ReferenceData.ViewModels.BrokerFeeRules" mc:Ignorable="d" HorizontalAlignment="Stretch" HorizontalContentAlignment ="Stretch" d:DesignHeight="300" d:DesignWidth="300"> <UserControl.Resources> <ObjectDataProvider x:Key="BrokeerFeeRuleOperationTypes" ObjectType="{x:Type BrokerFeeRules:EnumHelper}" MethodName="ToDescriptions"> <ObjectDataProvider.MethodParameters> <x:Type TypeName="BrokerFeeRules:BrokerFeeRuleOperator"/> </ObjectDataProvider.MethodParameters> </ObjectDataProvider> <Editors:ComboBoxItemsProvider x:Key="BrokeerFeeRuleOperationTypesProvider" ItemsSource="{Binding Source={StaticResource BrokeerFeeRuleOperationTypes}}" /> <BrokerFeeRules:EnumToDescriptionConverter x:Key="EnumToDescriptionConverter"/> </UserControl.Resources> <Grid HorizontalAlignment="Stretch" > <Grid.ColumnDefinitions> <ColumnDefinition Width="70"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <Editors:XamComboEditor Grid.Column="0" ItemsProvider="{StaticResource BrokeerFeeRuleOperationTypesProvider}" SelectedItem="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Controls1:BrokerFeeRuleConditionView} , Path=ConditionOp, Converter = {StaticResource EnumToDescriptionConverter}, ConverterParameter={x:Type BrokerFeeRules:BrokerFeeRuleOperator}}" /> <StackPanel Grid.Column="1" HorizontalAlignment="Stretch"> <Editors:XamTextEditor HorizontalAlignment="Stretch" MinWidth="200" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Controls1:BrokerFeeRuleConditionView} , Path=ConditionValue}" > </Editors:XamTextEditor> </StackPanel> </Grid> </UserControl>
It seems to work now. I had to to replace the Editor Style instead of the CellValuePresenter.
The only caveat is that I don't know how to implement my own custom editor, so I have used a XamTextEditor and replaced its Template and Edit Template, which is kind of a dirty hack. Is there a more elegant way to implement this? Please see below the XAML I'm using to setup a column.
Thanks.
P.S: How can I have syntax highlighting on my XAML?
<igDP:Field Name="CountryCode" Label="Country Code" Width="Auto" > <igDP:Field.Settings> <igDP:FieldSettings LabelTextWrapping="Wrap" AllowEdit="False" EditorType="{x:Type Editors:XamTextEditor}" > <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type Editors:XamTextEditor}" > <Setter Property="Template"> <Setter.Value> <ControlTemplate> <Controls1:BrokerFeeRuleConditionView HorizontalAlignment="Stretch" ConditionValue="{Binding DataItem.CountryCode}" ConditionOp="{Binding DataItem.CountryCodeOperator}" /> </ControlTemplate> </Setter.Value> </Setter> <Setter Property="EditTemplate"> <Setter.Value> <ControlTemplate> <Controls1:BrokerFeeRuleConditionView ConditionValue="{Binding DataItem.CountryCode}" ConditionOp="{Binding DataItem.CountryCodeOperator}" /> </ControlTemplate> </Setter.Value> </Setter> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:Field.Settings> </igDP:Field>
If you are just trying to have multiple properties from your viewmodel show in the same column of the grid, you can override the default column and row settings in the fieldLayout.
<igDP:FieldLayout >
<igDP:FieldLayout.Fields>
<igDP:Field Name="name" Row="1" Column="0" RowSpan="2" />
<igDP:Field Name="department" Row="1" Column="3" />
<igDP:Field Name="salary" Row="1" Column="2" RowSpan="2" />
<igDP:Field Name="email" Row="2" Column="3" />
</igDP:FieldLayout.Fields>
</igDP:FieldLayout>
Without being able to build a sample and see the behavior of your validation and of your Controls:BrokerFeeRuleConditionView, it’s hard for me to determine what is creating the behavior there.
If you could give me a small sample that duplicates the behavior, I can be more helpful with that issue.