gpt4 book ai didi

c# - ComboBox 项目的布局

转载 作者:行者123 更新时间:2023-11-30 22:49:57 24 4
gpt4 key购买 nike

我有 ComboBox 项目样式如下(简化):

<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="35"/>
</Grid.ColumnDefinitions>

<TextBlock Grid.Column="0" />
<Path Grid.Column="1" Style={StaticResource StarStyle}/>
</Grid>

结果符合预期。我列表中的一项如下所示:

alt text http://robbertdam.nl/share/p1.png

但是,当我选择该项目时。它看起来像这样:

alt text http://robbertdam.nl/share/p2.png

我想让星星右对齐。我错过了什么?

最佳答案

我忘了说我已经定义了这个 Style

        <Style x:Key="ComboItemsStyle" TargetType="{x:Type ComboBoxItem}">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
</Style>

将此样式分配给我的 ComboBox 解决了这个问题:

        <Style x:Key="ComboStyle" TargetType="{x:Type ComboBox}">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
</Style>

关于c# - ComboBox 项目的布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/857492/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com