开发者

DataTrigger does not work as expected

I have a ComboBox bound to a ViewModel property called Property.

Property is a TypeDescriptor.

When user changes the value in the 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, the DataTrigger is not working as e开发者_JAVA百科xpected.

<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>


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜