3

编辑:Pavel 已经表明这可能不是 VisualBrush 的错,所以我已经为我的具体问题重命名了这个问题。

该示例是 WPF 数据网格;向右滚动,直到列标题部分可见。拖动部分可见的列标题以重新排序。拖动指示器是标题的局部视图(不完整)

我的解决方案- 仍然对其他解决方案感兴趣,
我订阅了 ColumnReordering 并将拖动指示器替换为我自己的。为我自己的类复制 DataGridColumnFloatingHeader 的源。我将使用标题创建视觉画笔的线更改为使用标题的第一个子项(未剪裁)创建视觉画笔的线删除偏移并使用 0,0..

4

1 回答 1

0

编辑

我相信这是 DataGrid 实现中的一个错误。如果它真的对待你,我建议你滚动列开始以避免这种不需​​要的行为。

恕我直言,问题本身在System.Windows.Controls.DataGridColumnFloatingHeader. 由于这个类是内部的,所以很难解决这个问题。

如何重现:

向右滚动一点,而不是拖动第一列。

<Window x:Class="WpfApplication2.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="400" Width="300">

    <ScrollViewer x:Name="uiScroll">
        <DataGrid Grid.Row="3" x:Name="uiGrid">
            <DataGrid.Columns>
                <DataGridTextColumn Width="200" Header="Test 1" Binding="{Binding Key}" />
                <DataGridTextColumn Width="200" Header="Test 2" Binding="{Binding Value}" />
            </DataGrid.Columns>
        </DataGrid>
    </ScrollViewer>

</Window>

...

public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();

        uiGrid.ItemsSource = new Dictionary<string, string>() { { "key1", "val1" }, { "key2", "val2" } };
    }

}
于 2011-12-21T14:25:45.903 回答