我有一个PopupBox,我想更改图标。目前它默认为DotsVertical,我想将它作为DotsHorizo​​ntal

时间:2017-06-21 18:45:48

标签: wpf xaml material-design-in-xaml

我正在将MaterialDesignInXAML用于WPF应用程序。我有一个PopupBox,我想更改图标。目前默认为DotsVertical,我希望将其设为DotsHorizontal

我尝试了以下但没有运气。

<materialDesign:PopupBox PlacementMode="BottomAndAlignRightEdges" StaysOpen="False">
    <materialDesign:PopupBox.Content>
        <materialDesign:PackIcon Kind="DotsHorizontal" />
    </materialDesign:PopupBox.Content>
    <StackPanel>
        <TextBlock Text="Test1" />
        <TextBlock Text="Test2" />
        <TextBlock Text="Test3" />
    </StackPanel>
</materialDesign:PopupBox>

提前致谢!

2 个答案:

答案 0 :(得分:10)

想出来并在此处留下答案以防其他人遇到此问题。有一个名为ToggleContent

的属性
<materialDesign:PopupBox PlacementMode="BottomAndAlignRightEdges" StaysOpen="False">
    <materialDesign:PopupBox.ToggleContent>
        <materialDesign:PackIcon Kind="DotsHorizontal" />
    </materialDesign:PopupBox.ToggleContent>
    <StackPanel>
        <TextBlock Text="Test1" />
        <TextBlock Text="Test2" />
        <TextBlock Text="Test3" />
    </StackPanel>
</materialDesign:PopupBox>

答案 1 :(得分:0)

要更改图标并保留当前样式,请使用以下方法:

<materialDesign:PopupBox PlacementMode="BottomAndAlignRightEdges" StaysOpen="False">
     <materialDesign:PopupBox.ToggleContent>
         <materialDesign:PackIcon Kind="DotsHorizontal" 
                                Foreground="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=materialDesign:PopupBox}, Path=Foreground}"                        />
         </materialDesign:PopupBox.ToggleContent>
    <StackPanel>
        <TextBlock Text="Test1" />
        <TextBlock Text="Test2" />
        <TextBlock Text="Test3" />
    </StackPanel>
</materialDesign:PopupBox>