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
955
Validations - Column with two controls
posted

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.