11

I am using MaterialDesignInXAML for a WPF application. I have a PopupBox that I want to change the icon for. Currently it defaults to DotsVertical and I would like to have it as a DotsHorizontal.

I tried the following with no luck.

<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>

Thanks in advance!

2 Answers 2

22

Figured it out and will leave an answer here in case anyone else comes across this issue. There is a property called 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>
3

In order to change the Icon and preserve the current style use this:

<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>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.