I use microsoft tool kit in UWP and have something like this
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="7*"/>
<RowDefinition Height="3"/>
<RowDefinition Height="3*"/>
<RowDefinition Height="4*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="3*"/>
</Grid.ColumnDefinitions>
</Grid>
<Grid Grid.Row="1">
<controls:GridSplitter ResizeBehavior="PreviousAndNext" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" />
</Grid>
</Grid>
How can i set spliter's affection to column 1 only guys? i dont want column 0 to be resized like column 1. Like in the image,when i use splitter, i only want splitter resize column 1 only, column 0 is just freeze.
new code:
<Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition Height="7*"/>
<RowDefinition Height="3"/>
<RowDefinition Height="3*"/>
<RowDefinition Height="4*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="3*"/>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0" Background="Red"></Grid>
</Grid>
<Grid Grid.Row="1">
<controls:GridSplitter GripperCursor="Help" HorizontalAlignment="Stretch" Grid.Column="1" ResizeDirection="Columns"
ResizeBehavior="CurrentAndNext" CursorBehavior="ChangeOnSplitterHover" VerticalAlignment="Stretch" ></controls:GridSplitter>
</Grid>
<Grid Grid.Row="2">
<TextBlock Text="aoisdjaisodjaiosdjsa" Width="60" Height="60" VerticalAlignment="Center" HorizontalAlignment="Center"></TextBlock>
</Grid>
</Grid>
You have more than one Grid
so I don't know what grid you want your GridSplitter
but all you have to do is create a GridSplitter
with property Grid.Column
you want to put the control into.
Example:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="7*"/>
<RowDefinition Height="3"/>
<RowDefinition Height="3*"/>
<RowDefinition Height="4*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="3*"/>
</Grid.ColumnDefinitions>
</Grid>
<!-- Means GridSplitter stay on column 1 based on the grid he is -->
<controls:GridSplitter Grid.Column="1" ResizeBehavior="PreviousAndNext" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" />
<Grid Grid.Row="1">
<!-- Your XAML code here-->
</Grid>
</Grid>
You can use Grid.RowSpan
if you have to span over all the rows.
Like in the image,when i use splitter, i only want splitter resize column 1 only, column 0 is just freeze.
GridSplitter
has ResizeBehavior
property. For your requirement, you could set ResizeBehavior
as CurrentAndNext
and Grid.Column="1"
, then the column will be freezed. you could refer the following.
<controls:GridSplitter
GripperCursor="Help"
HorizontalAlignment="Left"
Grid.Column="1"
ResizeDirection="Columns"
ResizeBehavior="CurrentAndNext"
CursorBehavior="ChangeOnSplitterHover"
Width="10">
<controls:GridSplitter.RenderTransform>
<TranslateTransform X="-5" />
</controls:GridSplitter.RenderTransform>
</controls:GridSplitter>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.