1

I've never done any work in wpf before and i'm supposed to add an undo button. I want it to look like what the undo button in VS looks like (click to undo once, hover over to get the more in depth listbox). I managed to get whats in the picture. It is inside a menuitem and i can't figure out how to just make it a white box without any borders or anything. Please Help! Here's code:

 <MenuItem Header="Edit" Width="50" HorizontalContentAlignment="Center" >
            <MenuItem x:Name="MenuCopy" Header="Copy to Excel" >
                <MenuItem.Icon>
                    <Image Source="copy.ico" Width="24" Height="24"  />
                </MenuItem.Icon>
            </MenuItem>
            <MenuItem x:Name="MenuUndo" Header="Undo Last Action" IsEnabled="true">
                <MenuItem.Icon>
                    <Image Source="Undo.png" Width="24" Height="24" />
                </MenuItem.Icon>
                <ListBox>
                    <ListBoxItem Name="Item" Height="10" Width="100">

                    </ListBoxItem>

                </ListBox>
            </MenuItem>

enter image description here

2
  • Do you want the whole submenu item to just be a white box? Commented Jun 8, 2016 at 20:42
  • yeah that's exactly what I was thinking Commented Jun 9, 2016 at 12:18

1 Answer 1

1

you may try to override the ControlTemplate and set the styles and remove padding, borders.

<Setter Property="Control.Template">
    <Setter.Value>
        <ControlTemplate TargetType="ListBox">
           ...
        </ControlTemplate>
    </Setter.Value>
</Setter>

Check this msdn link for Listbox style.

Sign up to request clarification or add additional context in comments.

2 Comments

Sorry I am not familiar to wpf at all. Would this go inside the list box or around the list box?
This is the style of Listbox. You can edit styles and apply it to your control. check the msdn link.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.