gpt4 book ai didi

wpf - 通过 WPF 样式或触发器设置 TaskbarItemInfo

转载 作者:行者123 更新时间:2023-12-01 04:05:52 24 4
gpt4 key购买 nike

WPF 4 包括一个“TaskbarItemInfo”Freezable 类,该类将附加属性添加到允许更改各种 Windows 7 任务栏项目的窗口。

特别是,我正在尝试在窗口的 tasbar 图标上设置进度信息。我想使用 DataTrigger 来执行此操作,但它似乎不起作用。我尝试使用简单的样式 setter ,但这也不起作用 - 只有直接属性分配或直接属性绑定(bind)才能起作用。

例如:

<Window.Style>
<Style>
<Setter Property="TaskbarItemInfo.ProgressState" Value="Indeterminate" />
</Style>
</Window.Style>

<Window.TaskbarItemInfo>
<TaskbarItemInfo />
</Window.TaskbarItemInfo>

看起来好像附加属性不是通过样式设置的。我通过样式设置附加属性的语法不正确,还是我遗漏了其他东西?

最佳答案

TaskbarItemInfo不继承自 FrameworkElement所以没有Style属性供您在 DataTrigger 中设置.

你为什么不绑定(bind)你的TaskbarItemInfoProgressState到您想在 DataTrigger 中使用的属性然后使用 ValueConverter将其转换为相关的 TaskbarItemProgressState .

<Window.TaskbarItemInfo>
<TaskbarItemInfo ProgressState="{Binding YourProperty, Mode=OneWay, Converter={StaticResource ProgressStateConverter}}" />
</Window.TaskbarItemInfo>

然后一个简单的转换器可以返回任何一个 TaskbarItemProgressState适用于您的触发器属性。

关于wpf - 通过 WPF 样式或触发器设置 TaskbarItemInfo,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9417499/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com