Replacing a ComboBox's Drop-Down with a Menu
How would I replace a ComboBox's default drop-开发者_高级运维down list with a menu?
I realized that it was a lot easier to style a <Menu>
to look like a <ComboBox>
than it was to make a <ComboBox>
show a menu.
Here's a blog post describing how to do this.
If all you are after is for the ComboBox dropdown to look like a menu then you don't need to replace anything as the ComboBox accepts arbitrary content.
E.g.
<Grid>
<ComboBox Margin="25" MaxHeight="25">
<TextBlock Text="Hello" />
<TextBlock Text="Hello" />
<TextBlock Text="Hello" />
<TextBlock Text="Hello" />
<Separator />
<TextBlock Text="Hello" />
<TextBlock Text="Hello" />
<TextBlock Text="Hello" />
<Separator />
<TextBlock Text="Hello" />
</ComboBox>
</Grid>
精彩评论