Put them into individual Grids
, use a column with a common SharedSizeGroup
and set Grid.IsSharedSizeScope
to true
on the StackPanel
.
Give equal width to controls inside a Stack Panel
-
30-05-2022 - |
Вопрос
I need to have two RadChart
s inside a horizontal StackPanel
and want both the charts to be of equal width. I don't want to give explicit length to the width of the charts. This can be easily achieved by using a Grid
control but my scenario requires a StackPanel
.
Решение 2
Другие советы
Often the documentation is not quickly comprehensible because it is either written in a confusing way or the needed information is hidden among a ton of other information that doesn't help in the particular case. And so, in my opinion, even if it is a "basic thing", it doesn't hurt to give a quick answer (or if one thinks it is too primitive, he/she should just post nothing at all).
<StackPanel Orientation="Horizontal" Grid.IsSharedSizeScope="True">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition SharedSizeGroup="MySizeGroup" />
</Grid.ColumnDefinitions>
<Button Height="23" Content="Reset" Padding="5,1" />
</Grid>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition SharedSizeGroup="MySizeGroup" />
</Grid.ColumnDefinitions>
<Button Height="23" Content="Set" Padding="5,1" />
</Grid>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition SharedSizeGroup="MySizeGroup" />
</Grid.ColumnDefinitions>
<Button Height="23" Content="Import" Padding="5,1" />
</Grid>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition SharedSizeGroup="MySizeGroup" />
</Grid.ColumnDefinitions>
<Button Height="23" Content="Export" Padding="5,1" />
</Grid>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition SharedSizeGroup="MySizeGroup" />
</Grid.ColumnDefinitions>
<Button Height="23" Content="Create new" Padding="5,1" />
</Grid>
</StackPanel>
Hope this helps :)
Не связан с StackOverflow