是否可以在 Expression Blend 3 中查看设计中数据触发器的效果?
Blend 支持显示样式资源的图形表示,并允许您选择要查看或修改的活动属性/事件触发器。然而,由 DataTriggers 控制视觉元素的情况很常见。是否可以告诉设计器应该将 DataTrigger 视为“活动”,以便可以在设计器中查看其视觉变化?
示例:
<Style x:Key="MyBorder" TargetType="Border">
<Setter Property="CornerRadius" Value="5" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsRandomPropertyActive}" Value="True">
<Setter Property="Background">
<Setter.Value>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="#FFFF8935" Offset="0" />
<GradientStop Color="#FFFF610C" Offset="1" />
</LinearGradientBrush>
</Setter.Value>
</Setter>
</DataTrigger>
</Style.Triggers>
</Style>
在设计器中,这仅显示一个空框,因为默认样式没有定义特定的视觉方面。无论如何,有没有办法告诉设计师我希望它假设 IsRandomPropertyActive 为 true,并显示适当的样式?
Blend supports displaying the graphical representation of a style resource, and allows you to select an active property/event trigger to view or modify. However, it's a common occurrence to have visual elements controlled by DataTriggers. Is it possible to tell the designer that it should consider a DataTrigger 'active' so that its visual changes can be viewed in the designer?
Example:
<Style x:Key="MyBorder" TargetType="Border">
<Setter Property="CornerRadius" Value="5" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsRandomPropertyActive}" Value="True">
<Setter Property="Background">
<Setter.Value>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="#FFFF8935" Offset="0" />
<GradientStop Color="#FFFF610C" Offset="1" />
</LinearGradientBrush>
</Setter.Value>
</Setter>
</DataTrigger>
</Style.Triggers>
</Style>
In the designer, this simply displays an empty box as the default style defines no specific visual aspects. Is there anyway to tell the designer that I want it to assume IsRandomPropertyActive is true, and display the appropriate styling?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您将模拟 ViewModel 与 Blend 结合使用,一个不错的技巧是从项目中单独的 XAML 文件加载设计时 ViewModel。如果执行此操作,您可以轻松更改 Blend 内的 XAML,并立即看到更改生效。例如,您可以将模拟 ViewModel 的 XAML 更改为:
我不知道有任何更简单的方法来实现您想要的功能。
If you are using mock ViewModels with Blend, a nice trick is to load your design-time ViewModels from a separate XAML file in the project. If you do this you can easily change the XAML inside Blend and immediately see the changes take effect. For example, you would change your XAML for the mock ViewModel to say:
I am not aware of any simpler way to achieve the functionality you desire.