如何在水平单选按钮组中节省空间?

时间:2016-05-11 15:18:11

标签: uwp-xaml

通常不是UI用户,但不知怎的,我最终负责这个应用程序: - )。

我有一个用户控件,它是网格内的单选按钮组。我试图指示每个单选按钮只能显示文本的宽度。看起来很琐碎,但即使我硬编码宽度,我似乎也无法影响它。无论我如何均匀分开3个选项。

    <Grid>
    <ItemsControl x:Name="DynamicRadioButtonItemsControl" ItemsSource="{x:Bind Options, Mode=OneWay}">
        <ItemsControl.ItemsPanel>
            <ItemsPanelTemplate>
                <StackPanel x:Name="RadioButtonStackPanel" Orientation="Horizontal" />
            </ItemsPanelTemplate>
        </ItemsControl.ItemsPanel>
        <ItemsControl.ItemTemplate>
            <DataTemplate>
                <RadioButton GroupName="{Binding GroupId, ElementName=InspectionItemRadioButtons}"  Content="{Binding Display}" Width="Auto"  Tag="{Binding Value}"  Checked="RadioButton_Checked"  Loading="RadioButton_Loading" />
            </DataTemplate>
        </ItemsControl.ItemTemplate>
    </ItemsControl>
</Grid>

1 个答案:

答案 0 :(得分:1)

尝试设置MinWidth属性,如下所示:

<RadioButton GroupName="{Binding GroupId, ElementName=InspectionItemRadioButtons}" 
    MinWidth="20" Content="{Binding Display}" Width="Auto"  Tag="{Binding Value}"  
    Checked="RadioButton_Checked" Loading="RadioButton_Loading" />