切换按钮 IsChecked 属性 wpf 中的字体已更改
我有一个切换按钮:
<Label x:Name="Text" FontWeight="Bold" Foreground="#FF1B6625" Margin="30,0,0,0"
FontSize="15" Background="#0016792C" Content="pause"
FontFamily="/UIapp;component/Resources/Fonts/#Arial"
VerticalAlignment="Top" Height="40"
HorizontalAlignment="Left"/>
<Image x:Name="Icon"
Width="14" Height="14"
Margin="10,8,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"
Source="{DynamicResource PlayIcon}">
</Image>
在 ControlTemplate.Triggers 中我有:
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="Icon" Property="Source" Value="{DynamicResource PauseIcon}" />
<Setter TargetName="Text" Property="Content" Value="play"/>
<Setter TargetName="Text" Property="Margin" Value="25,0,0,0" />
</Trigger>
</ControlTemplate.Triggers>
但由于某种原因,当我单击该按钮时,我得到的字体与单击之前不同。
知道原因吗?
谢谢
I've a toggle button :
<Label x:Name="Text" FontWeight="Bold" Foreground="#FF1B6625" Margin="30,0,0,0"
FontSize="15" Background="#0016792C" Content="pause"
FontFamily="/UIapp;component/Resources/Fonts/#Arial"
VerticalAlignment="Top" Height="40"
HorizontalAlignment="Left"/>
<Image x:Name="Icon"
Width="14" Height="14"
Margin="10,8,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"
Source="{DynamicResource PlayIcon}">
</Image>
and in ControlTemplate.Triggers i have :
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="Icon" Property="Source" Value="{DynamicResource PauseIcon}" />
<Setter TargetName="Text" Property="Content" Value="play"/>
<Setter TargetName="Text" Property="Margin" Value="25,0,0,0" />
</Trigger>
</ControlTemplate.Triggers>
but from some reason, when i click on the button, i get a different font than it was before the click.
any idea for the reason ?
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
无法理解标签和切换按钮之间的关系。
对于字体更改,请尝试使用 Snoop 工具。
这可以帮助您了解字体更改的原因。
Cant understand the relation between Label and toggle button.
For font change, try using Snoop tool.
This may help you in understanding the cause of font change.