开发者

Replacing a ComboBox's Drop-Down with a Menu

开发者 https://www.devze.com 2023-02-05 07:28 出处:网络
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 &l

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

精彩评论

暂无评论...
验证码 换一张
取 消