C# XAML中的图像按钮
有人能帮忙吗 我正在尝试制作以下代码,这样我就可以将我想要的任何图像注入到这个按钮样式中。因为此按钮样式在整个应用程序中都使用C# XAML中的图像按钮,c#,wpf,xaml,C#,Wpf,Xaml,有人能帮忙吗 我正在尝试制作以下代码,这样我就可以将我想要的任何图像注入到这个按钮样式中。因为此按钮样式在整个应用程序中都使用 <Style TargetType="Button" x:Key="ButtonIsChecked"> <Setter Property="Background" Value="Transparent"/> <Setter Property="BorderBrush" Value="Trans
<Style TargetType="Button" x:Key="ButtonIsChecked">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="Focusable" Value="False"/>
<Setter Property="Margin" Value="5"/>
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<CheckBox Content="{Binding Content}" Name="CheckBox_Logon" IsHitTestVisible="False" IsChecked="False">
<CheckBox.Template>
<ControlTemplate TargetType="{x:Type CheckBox}">
<WrapPanel>
<Image
Source="/AdminUltimate;component/Images/Icons/Windows.ico"
Width="15" Margin="3"
Visibility="{Binding IsChecked, Converter={StaticResource BoolToVis}, ElementName=DisableIcons}"/>
<TextBlock Text="{Binding}" VerticalAlignment="Center"/>
</WrapPanel>
</ControlTemplate>
</CheckBox.Template>
</CheckBox>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
当前使用
<Button Content="Login" Style="{StaticResource ButtonIsChecked}"/>
我想做一些像
<Button Content="Login" Style="{StaticResource ButtonIsChecked}" imgsrc="Pathtoimage"/>
这可能吗 一种快速且易于使用的方法,通过它来背载依赖项字符串,如下所示:
然后像这样实现
<Button Style="{StaticResource ButtonIsChecked}" Tag="/AdminUltimate;component/Images/Icons/Windows.ico"/>
希望这有帮助
<Button Style="{StaticResource ButtonIsChecked}" Tag="/AdminUltimate;component/Images/Icons/Windows.ico"/>