Monday, November 7, 2011

XamComboEditor - controlling combo Item selections

I needed to control how user can selected items in combo box drop down.
ItemContainerStyle whose value would be a style for target type ComboBoxItem.
IsEnabled property is bound to a MultiValueConverter. datacontext itself, current comboitem were passed as parameters to determine if its selectable.
Additional properties were set disallow keyboard focus, horizontal, vertical content alignment were stretched as below.

 <Setter Property="KeyboardNavigation.DirectionalNavigation" Value="None"/>

<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
 <Setter Property="VerticalContentAlignment" Value="Stretch"/>


               <Setter>
                    <Setter.Property>IsEnabled</Setter.Property>
                    <Setter.Value>
                        <MultiBinding Converter="{StaticResource sampleMultiConverter}" Mode="OneWay">
                            <Binding ElementName="xyzCmb" Path="DataContext" />
                            <Binding />
                        </MultiBinding>
                    </Setter.Value>
                </Setter>

No comments:

Post a Comment