views:

82

answers:

1

I have a combobox bound to a ViewModel property called "Property".

"Property" is a TypeDescriptor.

When user changes value in combobox the "Property" is updated.

On the UI i would like to either hide or make visible different controls: textbox, combobox, date picker etc.

Problem is datatrigger is not working as expected.

<Style x:Key="textboxStyle"
               TargetType="{x:Type TextBox}">
            <Style.Triggers>
                <DataTrigger Binding="{Binding Path=Property.PropertyType}"
                             Value="{x:Type Type={x:Type sys:String}}">
                    <Setter Property="Visibility"
                            Value="Visible" />
                </DataTrigger>
            </Style.Triggers>
        </Style>
A: 

You might need to write a Converter which gets invoked when the value of 'Property' changes. The converter can be a 'TypeDescriptior to Visibility converter. The reason why the above doesnt work is because 'PropertyType' doesnt trigger INotifyPropertyChanged.

Jobi Joy