C# XAML,辅助按钮不是';t显示

C# XAML,辅助按钮不是';t显示,c#,wpf,xaml,C#,Wpf,Xaml,因此,我尝试使用xaml在同一位置使用两个按钮,一个是播放按钮,另一个是暂停按钮,但出于某种原因,目前还不能完全确定原因,但只有xaml中的第一个按钮会显示,如果我将此给定按钮设置为隐藏,则第二个按钮永远不会被渲染 有什么想法吗 这是密码 <DataGridTemplateColumn Width="100"> <DataGridTemplateColumn.CellTemplate> <DataTemplate>

因此,我尝试使用xaml在同一位置使用两个按钮,一个是播放按钮,另一个是暂停按钮,但出于某种原因,目前还不能完全确定原因,但只有xaml中的第一个按钮会显示,如果我将此给定按钮设置为隐藏,则第二个按钮永远不会被渲染

有什么想法吗

这是密码

<DataGridTemplateColumn Width="100">
    <DataGridTemplateColumn.CellTemplate>
        <DataTemplate>
            <DockPanel Width="50" Height="50" VerticalAlignment="Center" HorizontalAlignment="Center">
                <Button Style="{DynamicResource MetroCircleButtonStyle}" Visibility="Hidden" Name="PlayButton"
                                            Width="50" Height="50" HorizontalAlignment="Center"
                                            VerticalAlignment="Center" Click="OnPlayButtonClicked"
                                            d:DataContext="{d:DesignInstance local:MainWindow}">
                    <Rectangle Width="20"
                                                   Height="20">
                        <!--<Image Width="50" Height="50" Source="Resources/playIcon.png"  Name="Image"></Image>-->
                        <Rectangle.Fill>
                            <VisualBrush Stretch="Fill"
                                                             Visual="{StaticResource appbar_control_play}" />
                        </Rectangle.Fill>
                    </Rectangle>
                    <!--<Image Width="50" Height="50" Source="Resources/playIcon.png"  Name="Image"></Image>-->
                </Button>

                <Button Style="{DynamicResource MetroCircleButtonStyle}" Visibility="Visible" Name="PauseButton"
                                            Width="50" Height="50" HorizontalAlignment="Center"
                                            VerticalAlignment="Center" Click="OnPauseButtonClicked"
                                            d:DataContext="{d:DesignInstance local:MainWindow}">
                    <Rectangle Width="20"
                                                   Height="20">
                        <!--<Image Width="50" Height="50" Source="Resources/playIcon.png"  Name="Image"></Image>-->
                        <Rectangle.Fill>
                            <VisualBrush Stretch="Fill"
                                                             Visual="{StaticResource appbar_control_pause}" />
                        </Rectangle.Fill>
                    </Rectangle>
                    <!--<Image Width="50" Height="50" Source="Resources/playIcon.png"  Name="Image"></Image>-->
                </Button>
            </DockPanel>
        </DataTemplate>
    </DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>

使用
网格
而不是
文档面板

<Grid Width="50" Height="50" VerticalAlignment="Center" HorizontalAlignment="Center">
    <Button Style="{DynamicResource MetroCircleButtonStyle}" Visibility="Hidden" Name="PlayButton"
                                            Width="50" Height="50" HorizontalAlignment="Center"
                                            VerticalAlignment="Center" Click="OnPlayButtonClicked"
                                            d:DataContext="{d:DesignInstance local:MainWindow}">
        <Rectangle Width="20"
                                                   Height="20">
            <!--<Image Width="50" Height="50" Source="Resources/playIcon.png"  Name="Image"></Image>-->
            <Rectangle.Fill>
                <VisualBrush Stretch="Fill"
                                                             Visual="{StaticResource appbar_control_play}" />
            </Rectangle.Fill>
        </Rectangle>
        <!--<Image Width="50" Height="50" Source="Resources/playIcon.png"  Name="Image"></Image>-->
    </Button>

    <Button Style="{DynamicResource MetroCircleButtonStyle}" Visibility="Visible" Name="PauseButton"
                                            Width="50" Height="50" HorizontalAlignment="Center"
                                            VerticalAlignment="Center" Click="OnPauseButtonClicked"
                                            d:DataContext="{d:DesignInstance local:MainWindow}">
        <Rectangle Width="20"
                                                   Height="20">
            <!--<Image Width="50" Height="50" Source="Resources/playIcon.png"  Name="Image"></Image>-->
            <Rectangle.Fill>
                <VisualBrush Stretch="Fill"
                                                             Visual="{StaticResource appbar_control_pause}" />
            </Rectangle.Fill>
        </Rectangle>
        <!--<Image Width="50" Height="50" Source="Resources/playIcon.png"  Name="Image"></Image>-->
    </Button>
</Grid>