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
1485
Set ComboEditorTool SelectedIndex based on a DataTrigger
posted

Hi,

I'm binding some ComboEditorTool controls to lists containing a Id (type Guid) and a Name (String).  When the selection is null, it displays an empty Guid (00000000-0000-0000-0000-000000000000).  So far in code I've been checking for this condition and manually setting the SelectedIndex to -1, which in turns displays a blank in the ComboEditorTool instead - much more user-friendly than a string of zeros! :)

I'd like to get this out of the code (to avoid repeating, and eliminate chances of forgetting to do this in some weird condition.)  I've been trying to use a DataTrigger, but so far no luck - the string of zeros (empty Guid) is always displayed.  Here's my latest attempt:

 

<igRibbon:ComboEditorTool
    x:Name="ClassificationVersionComboBox"
    Grid.Row="2"
    Grid.Column="1"
    DisplayMemberPath="Name"
    ValuePath="Id"
    ValueType="{x:Type sys:Guid}"
    HorizontalContentAlignment="Stretch"
    SelectedItemChanged="ClassificationVersionComboBox_SelectedItemChanged"
    >
    <igRibbon:ComboEditorTool.Style>
        <Style>
            <Style.Triggers>
                <DataTrigger Binding="{Binding Path=Value}">
                    <DataTrigger.Value>
                        <sys:Guid>00000000-0000-0000-0000-000000000000</sys:Guid>
                    </DataTrigger.Value>
                    <Setter Property="SelectedIndex" Value="-1"></Setter>
                </DataTrigger>
                <DataTrigger Binding="{Binding ElementName=ClassificationComboBox, Path=SelectedIndex}" Value="-1">
                    <Setter Property="igRibbon:ComboEditorTool.IsEnabled" Value="False"></Setter>
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </igRibbon:ComboEditorTool.Style>
</igRibbon:ComboEditorTool>

 

The second DataTrigger works fine, I just left it there so that all the XAML related to this ComboEditorTool is here.  I've also tried this: <sys:Guid>{00000000-0000-0000-0000-000000000000}</sys:Guid> (note curly brackets) with no luck.

I've run out of ideas so I figured I'd post this here to see if anyone sees what I'm doing wrong, or maybe this just isn't possible in XAML?

Thanks,
Michel