UI.WPF.Modern icon indicating copy to clipboard operation
UI.WPF.Modern copied to clipboard

Can RadioButtons be arranged at intervals?

Open wuyang26 opened this issue 1 year ago • 1 comments

Can RadioButtons be arranged at intervals?

The current method is similar to Grid, but it is not good when the length of the items is different.

wuyang26 avatar Sep 05 '24 23:09 wuyang26

Sorry, i didn't understand

NotYoojun avatar Oct 01 '24 15:10 NotYoojun

The current arrangement is similar to this: image

But I would prefer this way: image

That is to say, we hope the arrangement method is mainly based on item intervals, rather than fixed widths of item

wuyang26 avatar Oct 08 '24 03:10 wuyang26

Try setting the MinWidth property to 0 on the radio buttons

NotYoojun avatar Oct 08 '24 04:10 NotYoojun

After setting the MinWidth property to 0,the problem still exists. You can test the app example by setting radio button content of different lengths size ,like the abrove.

wuyang26 avatar Oct 11 '24 10:10 wuyang26

Check this code:

<ikw:SimpleStackPanel HorizontalAlignment="Center" VerticalAlignment="Center"
    Spacing="15" Orientation="Horizontal">

    <FrameworkElement.Resources>
        <Style TargetType="RadioButton" BasedOn="{StaticResource {x:Static ui:ThemeKeys.DefaultRadioButtonStyleKey}}">
            <Setter Property="MinWidth" Value="0"/>
            <Setter Property="Background" Value="AliceBlue"/>
        </Style>
    </FrameworkElement.Resources>

    <RadioButton Content="Radio"/>
    <RadioButton Content="Radio Button"/>
    <RadioButton Content="Station"/>
    <RadioButton Content="Button Radio"/>

</ikw:SimpleStackPanel>

image

NotYoojun avatar Oct 12 '24 21:10 NotYoojun

Just using RadioButton is definitely not a problem.however, there are issues with using the RadioButtons control

<ui:RadioButtons HorizontalAlignment="Left" VerticalAlignment="Top" SelectedIndex="{Binding Group2SelectedIndex}" MaxColumns="15"> <RadioButton Content="Option 1 length"/> <RadioButton Content="Option 2"/> <RadioButton Content="Option 3 length"/> <RadioButton Content="Option 4"/> <RadioButton Content="Option 5"/> </ui:RadioButtons>

wuyang26 avatar Oct 30 '24 07:10 wuyang26

No, you can't do that. Please see the source code of ui:RadioButtons (https://github.com/iNKORE-NET/UI.WPF.Modern/blob/main/source/iNKORE.UI.WPF.Modern.Controls/Controls/Windows/RadioButtons/RadioButtons.xaml).

Inside the component a UniformGrid-based panel is used for layout, and this makes your idea not possible. Alternately, a better idea is to use ItemsControl and RadioButton control.

If there's anything else, feel free to reply, reopen this issue, or create a new issue!

NotYoojun avatar Nov 01 '24 11:11 NotYoojun