C# 切换WPF中图像中的按钮内容更改
我在wpf中有使用切换按钮的代码C# 切换WPF中图像中的按钮内容更改,c#,wpf,togglebutton,C#,Wpf,Togglebutton,我在wpf中有使用切换按钮的代码 <Grid> <ToggleButton x:Name="pinButton" VerticalAlignment="Center" Width="auto" MaxWidth="26" Height="26" Background="{DynamicResource MyBorderBlueGradientBrush}" Focusable="
<Grid>
<ToggleButton x:Name="pinButton" VerticalAlignment="Center" Width="auto" MaxWidth="26" Height="26"
Background="{DynamicResource MyBorderBlueGradientBrush}" Focusable="False"
DockPanel.Dock="Right" BorderThickness="0"
OverridesDefaultStyle="False" BorderBrush="{DynamicResource MyBorderBlueGradientBrush}" FontFamily="Webdings">
<Label x:Name="Pinback" Background="{DynamicResource MyBorderBlueGradientBrush}" Width="26" Height="26" BorderBrush="{DynamicResource MyBorderBlueGradientBrush}">
<Label x:Name="Pin" FontSize="18" Foreground="White" Content="" Width="25" Height="25" Background="Black" HorizontalAlignment="Center" VerticalAlignment="Center">
<Label.RenderTransform>
<RotateTransform Angle="16" CenterX="29" CenterY="0"></RotateTransform>
</Label.RenderTransform>
</Label>
</Label>
</ToggleButton>
</Grid>
当我运行这个代码时,我得到了这个窗口
因此,我的问题是“内容如何转换为pin图像”。当我更改内容时,它会转换为其他图像。pin来自XAML中的
WebFontFamily
中的一个字符:
<Label x:Name="Pin" FontSize="18" Foreground="White" Content="" Width="25"
Height="25" Background="Black" HorizontalAlignment="Center"
VerticalAlignment="Center" />
这是否可以
Content=”"代码>是你的问题吗?我删除了““
从我的测试项目和pin码消失可能重复@Gimly这是错误请求不是‘如何’问题,我对vikky正确吗?@LIUFA好吧,vikky试图做的与我链接的SO问题中给出的解决方案明显相同。方法不同,但链接中的方法是推荐的方法谢谢你的回答。我已经找到了完整的Webdings字符集。我相信它们包含在Windows PC的标准字体中。
<ToggleButton x:Name="pinButton" VerticalAlignment="Center" Width="auto" MaxWidth="26"
Height="26" Background="Blue" Focusable="False" DockPanel.Dock="Right"
BorderThickness="0" OverridesDefaultStyle="False" BorderBrush="Blue"
FontFamily="Webdings">