wpf - wpf datagrid itemscontrol gridsplitter dont move
问题描述
there is my code
<Grid Grid.Row="2" Margin="10,0,10,5">
<Border BorderBrush="DarkGray" BorderThickness="1"></Border>
<ScrollViewer BorderBrush="White" BorderThickness="10" Margin="1">
<ItemsControl ItemsSource="{Binding DataViews,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Grid.IsSharedSizeScope="True">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<DataGrid Grid.Row="0" MaxHeight="400" VerticalScrollBarVisibility="Auto" VerticalAlignment="Stretch" Margin="0,0,10,0" MaxColumnWidth="450"
RowStyle="{StaticResource DataGridRowSql}" Style="{StaticResource DataGridStyleSQL}"
ColumnHeaderStyle="{StaticResource StyleDataGridColumnHeaderDefault}" ItemsSource="{Binding}"
IsReadOnly="{Binding RelativeSource={RelativeSource AncestorType=Page},Path=Locked}"
RowEditEnding="DataGrid_RowEditEnding" AutoGeneratingColumn="DataGrid_AutoGeneratingColumn">
<DataGrid.CommandBindings>
<CommandBinding Command="Copy" Executed="CommandBinding_Executed"></CommandBinding>
</DataGrid.CommandBindings>
<DataGrid.InputBindings>
<KeyBinding Key="C" Modifiers="Ctrl" Command="Copy"></KeyBinding>
</DataGrid.InputBindings>
</DataGrid>
<GridSplitter Grid.Row="1" Background="Red" Height="10" HorizontalAlignment="Stretch" ResizeDirection="Rows" ResizeBehavior="PreviousAndNext"></GridSplitter>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel VerticalAlignment="Stretch"></StackPanel>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</ScrollViewer>
</Grid>
the problem is that everything is seen perfectly but when you drag the gridsplitter everything stays exactly as it is, nothing moves at all, where am I wrong?
解决方案
尝试更改它,使您有 3 行,并且 gridsplitter 填充第 1 行。
像这样:
<Grid>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition Height="10"/>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<GridSplitter Grid.Row="1" Background="Red"
HorizontalAlignment="Stretch"
ResizeDirection="Rows"
ResizeBehavior="PreviousAndNext"/>
可能还有其他一些问题——因为里面有很多复杂的东西。然而。我只是在一个窗口中尝试了您的标记,但它在那里不起作用。
这样做:
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition Height="10"/>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<GridSplitter Grid.Row="1" Background="Red"
HorizontalAlignment="Stretch"
ResizeDirection="Rows"
ResizeBehavior="PreviousAndNext"/>
<Rectangle Fill="Yellow"/>
<Rectangle Fill="Lavender" Grid.Row="2"/>
</Grid>
</Window>
推荐阅读
- javascript - Ajax/PageMethod 都返回完整页面 HTML 而不是执行 webmethod 并正确返回
- angular - 如何将复选框动态添加到角度形式(Angular 4)
- tensorflow - 为什么在训练我的模型时我在 Keras 中的损失没有改变?
- php - Silverstripe 4 中的 GroupedList,按 many_many_extrafield 分组
- node.js - 如何解析带有文件路径作为变量之一的查询字符串并使用该文件路径变量下载文件?
- android - Python 3 的 Kivy Buildozer 要求错误
- c# - 使用 Linq 查找具有属性的构造函数
- linux - 执行 JAR 文件后如何在命令行中仅模拟一个 ENTER
- ios - 如何确定 iOS 上支持小写的字体是什么?
- javascript - NPM 启动开发服务器问题