The*_*der 7 silverlight xaml triggers
<TextBlock Text="{Binding MyTextProperty}">
<TextBlock.Style>
<Style TargetType="{x:Type TextBox}">
<Style.Triggers>
<DataTrigger Binding="{Binding MyTextProperty}" Value="{x:Null}">
<Setter Property="Text" Value="Hey, the text should not be empty!" />
<Setter Property="Foreground" Value="Red" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
Run Code Online (Sandbox Code Playgroud)
问题1:为什么要<Style TargetType="{x:Type TextBox}">给出错误The type 'x:Type' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.
问题2:为什么我收到错误 The attachable property 'Triggers' was not found in type 'Style'.
我错过了什么吗?
Col*_*inE 11
看起来您正在尝试在Silverlight中使用WPF XAML.Silverlight不支持{x:Type}标记扩展.你可以改用TargetType={TextBox}.
此外,Silverlight没有DataTrigger支持!
看到:
什么是Silverlight中DataTrigger的替代品
| 归档时间: |
|
| 查看次数: |
8685 次 |
| 最近记录: |