数据绑定 – Windows应用商店应用中条件样式(或Style.Triggers-&
我已经用尽了互联网搜索,似乎找不到基于数据绑定条件设计
Windows Store App XAML元素的最佳实践?
< Style.Triggers>< DataTrigger> …< / DataTrigger>< /Style.Triggersu0026gt;在Windows 8商店应用程序中似乎不像在WPF中那样可用,而Visual State Manager仅用于预先设置的交互状态,例如MouSEOver不是吗?如何根据我的基础View模型显着更改我的UI? 要创建一个明确回答此问题的方案,更改< TextBlock />的最佳实践/最广泛接受的方法是什么?例如,从一种风格到另一种风格,取决于数据绑定条件?我说风格,因为我知道你可以使用转换器来获得类似颜色的东西,但是如果我的变化变得非常复杂呢?例如,添加边框,字体大小和背景颜色? 我的第二个场景是我想要替换< Path />的数据.标签取决于视图模型条件,这也可能吗?基本上,我有一个’cross’和’tick’XAML路径,并希望根据视图模型属性将它们交换出来. 我试图在可能的情况下坚持MVVM,所以也不希望在我的代码背后硬编码样式引用. 谢谢大家. 解决方法
VisualStateManager就是你想要的.从
here开始:
我认为这足以涵盖你想要的东西. 来自同一链接的示例应该为您提供一些想法: <ControlTemplate TargetType="Button"> <Grid > <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="CommonStates"> <VisualStateGroup.Transitions> <!--Take one half second to transition to the PointerOver state.--> <VisualTransition To="PointerOver" GeneratedDuration="0:0:0.5"/> </VisualStateGroup.Transitions> <VisualState x:Name="Normal" /> <!--Change the SolidColorBrush,ButtonBrush,to red when the Pointer is over the button.--> <VisualState x:Name="PointerOver"> <Storyboard> <ColorAnimation Storyboard.TargetName="ButtonBrush" Storyboard.TargetProperty="Color" To="Red" /> </Storyboard> </VisualState> </VisualStateGroup> </VisualStateManager.VisualStateGroups> <Grid.Background> <SolidColorBrush x:Name="ButtonBrush" Color="Green"/> </Grid.Background> </Grid> </ControlTemplate> 请注意,您还可以从代码中更改VisualStateManager的状态,这一点很重要.请查看默认模板中的LayoutAwarePage.cs以获取此示例. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- emacs – Windows配置到寄存器
- windows-server-2008-r2 – 测试Windows用户帐户而不实际登
- Windows – 如何使用InnoSetup安装驱动程序?
- Windows服务 – Windows服务或计划任务,我们喜欢哪一个?
- windows-xp – IE8脚本错误800704a6?
- Window Server配置Flask
- windows-server-2012-r2 – iscsi Windows Server hyper-v集
- Windows – 标签完成和箭头键在Git Bash的GHCI中不起作用
- 如何往虚拟机内传文件的3种方法
- windows下nginx的安装和使用