c# - 如何设置 GridSplitter 对网格的喜爱
问题描述
我在 UWP 中使用 microsoft 工具包并有类似的东西
<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>
我怎样才能将拆分器的感情设置为仅列 1 的人?我不想像第 1 列那样调整第 0 列的大小。就像在图像中一样,当我使用拆分器时,我只希望拆分器调整第 1 列的大小,第 0 列只是冻结。
新代码:
<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>
解决方案
你有不止一个Grid
,所以我不知道你想要什么网格,GridSplitter
但你所要做的就是创建一个你想要将控件放入的GridSplitter
属性。Grid.Column
例子:
<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>
Grid.RowSpan
如果您必须跨越所有行,则可以使用。
推荐阅读
- angular - 位置对象的承载属性的目的是什么?
- python - 每 X 分钟执行一次逻辑(没有 cron)?
- django - django-rest-framework 聚合总和字段
- python - 3D Numpy 数组到数组转换的列表
- javascript - 样式加载器在 React SSR 中失败
- php - 使用从 foreach 返回的值创建动态数组
- python - 如何将图像的像素值复制到另一个python变量以使该python变量将图像保存在opencv中
- c# - MetadataAddress 或授权必须使用 HTTPS,除非通过设置 RequireHttpsMetadata=false 禁用开发
- django - 删除 django 和 api 中的对象
- python - python条码生成器中的条码行不相等