VariableSizedWrapGrid controls with different size in row

youki 996 Reputation points
2023-01-11T12:15:41.24+00:00

Why does the CheckBox doesn't fit to the right from the CombobBox if i change the width with the mouse. There is still a lot of room to the right from the CheckBox.

I've tried anything with MaximumRowsOrColumns, ColumnSpan and RowSpan but I can't figure it out.

[https://learn.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.variablesizedwrapgrid?view=winrt-22621

User's image


<Grid Grid.Row="1" Background="#272727" CornerRadius="3" Padding="0,10,0,0" Margin="0,0,15,0">

	<StackPanel Orientation="Vertical">

		<VariableSizedWrapGrid Orientation="Horizontal" Background="Green">

			<ComboBox x:Name="cmbApplication" 
				  CornerRadius="3" 
				  Width="300"
				  MaxWidth="300"
				  VariableSizedWrapGrid.ColumnSpan="2"
				  Margin="0,0,5,0" Background="Gray">

			</ComboBox>

			<CheckBox Name="cbApplication" Content="Aktiviert" Width="10" Background="Blue" ></CheckBox>

		</VariableSizedWrapGrid>

	</StackPanel>

</Grid>

Windows App SDK
Windows App SDK
A set of Microsoft open-source libraries, frameworks, components, and tools to be used in apps to access Windows platform functionality on many versions of Windows. Previously known as Project Reunion.
725 questions
0 comments No comments
{count} votes

Accepted answer
  1. Xiaopo Yang - MSFT 11,496 Reputation points Microsoft Vendor
    2023-01-12T05:49:53.61+00:00

    VariableSizedWrapGrid.ItemWidth Gets or sets the width of the layout area for each item that is contained in a VariableSizedWrapGrid and The default is NaN which means the VariableSizedWrapGrid uses the width of the first cell.

    VariableSizedWrapGrid.ColumnSpan Gets or sets a value that indicates the total number of columns that the element content spans within a parent VariableSizedWrapGrid.

    You can try VariableSizedWrapGrid.HorizontalChildrenAlignment Property. Stretch Property indicates An element stretched to fill the entire layout slot of the parent element.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. youki 996 Reputation points
    2023-01-12T09:59:36.1433333+00:00

    Great!

    I think i missed the ItemWidth and HorizontalChildrenAlignment in the VariableSizedWrapGrid tag.

    User's image

    <VariableSizedWrapGrid Orientation="Horizontal" MaximumRowsOrColumns="3" HorizontalChildrenAlignment="Left" ItemWidth="140" Background="Green">
    
    	<ComboBox" 
    		CornerRadius="3" 
    		Width="280"
    		MaxWidth="280"                                  
    		VariableSizedWrapGrid.ColumnSpan="2" Background="Gray">
    
    	</ComboBox>
    
    	<CheckBox Content="Aktiviert" VariableSizedWrapGrid.ColumnSpan="1" Background="Red"></CheckBox>
    
    </VariableSizedWrapGrid>
    
    0 comments No comments