Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wpf 切换按钮-单击即可更改图标_Wpf_Xaml_Mahapps.metro - Fatal编程技术网

Wpf 切换按钮-单击即可更改图标

Wpf 切换按钮-单击即可更改图标,wpf,xaml,mahapps.metro,Wpf,Xaml,Mahapps.metro,我在WPF中有一个应用程序。我正在使用entypo图标,并将其中一个标记为资源: <Grid.Resources> <iconPacks:Entypo x:Key="PlayIcon" Width="50" Height="30" Kind="ControllerPlay"></iconPacks:Entypo> </Grid.Resources> 有谁能告诉我,我是否能做到这一点(

我在WPF中有一个应用程序。我正在使用entypo图标,并将其中一个标记为资源:

<Grid.Resources>
  <iconPacks:Entypo x:Key="PlayIcon" Width="50" Height="30" Kind="ControllerPlay"></iconPacks:Entypo>                              
</Grid.Resources>

有谁能告诉我,我是否能做到这一点(稍加修改)或给我指出正确的方向吗?

你不能将
图像的
源代码设置为
PackIconEntypo
。改为设置
ToggleButton
Content
属性:

<ToggleButton>
    <ToggleButton.Style>
        <Style TargetType="{x:Type ToggleButton}">
            <Setter Property="Content" Value="{StaticResource PlayIcon}" />
            <Style.Triggers>
                <Trigger Property="IsChecked" Value="true">
                    <Setter Property="Content" Value="{StaticResource PauseIcon}" />
                </Trigger>
            </Style.Triggers>
        </Style>
    </ToggleButton.Style>
</ToggleButton>

这就是我想要的,很明显。谢谢:)
<ToggleButton>
    <ToggleButton.Style>
        <Style TargetType="{x:Type ToggleButton}">
            <Setter Property="Content" Value="{StaticResource PlayIcon}" />
            <Style.Triggers>
                <Trigger Property="IsChecked" Value="true">
                    <Setter Property="Content" Value="{StaticResource PauseIcon}" />
                </Trigger>
            </Style.Triggers>
        </Style>
    </ToggleButton.Style>
</ToggleButton>