拖动一些像素后,GridSplitter被卡住

时间:2019-03-06 08:45:40

标签: c# wpf draggable gridsplitter

GridSplitter在拖动一些像素后被卡住,必须重新选择拆分器并再次拖动。

我在第一列中使用RadTreeView,在第二列中使用ListBox,用户可以在其中选择ListBox中的项目并将其拖动到RadTreeView中。

请在下面的用户界面屏幕截图中找到

我试图找到SO的解决方案,但没有得到任何有用的答案。

请在下面找到相同的代码,如果需要更多信息,请告诉我。

Screenshot of Window

<UserControl x:Class="StructureDesigner.StructureDesigner"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
   xmlns:dragDrop="clr-namespace:Telerik.Windows.Controls.DragDrop;assembly=Telerik.Windows.Controls"
    xmlns:vm="clr-namespace:StructureDesigner.ViewModel"             
    MinHeight="400" MinWidth="400" AllowDrop="True" telerik:DragDropManager.AllowCapturedDrag="True" Name="StructureDesignerScreen">

    <UserControl.Resources>

        <Style TargetType="telerik:RadTreeViewItem">
            <Setter Property="AllowDrop" Value="true" />
            <Setter Property="telerik:DragDropManager.AllowCapturedDrag" Value="True" />
            <Setter Property="telerik:DragDropManager.AllowDrag" Value="True" />
        </Style>

        <Style TargetType="ListBoxItem">
            <Setter Property="telerik:DragDropManager.AllowCapturedDrag" Value="True" />
        </Style>

    </UserControl.Resources>

    <Grid x:Name="MainGrid" ScrollViewer.CanContentScroll="false" ScrollViewer.HorizontalScrollBarVisibility="Hidden" ScrollViewer.VerticalScrollBarVisibility="Hidden">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="300"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>

        <GridSplitter x:Name="gridSplitter" Grid.Row="0" Grid.Column="0" HorizontalAlignment="Right" Width="10" Background="DarkGray" Height="Auto"   />

        <telerik:RadTreeView x:Name="radStructureTreeView" IsDragTooltipEnabled="True" IsDragDropEnabled="True"
                             IsDragPreviewEnabled="True" IsDropPreviewLineEnabled="True"
                             Grid.Row="0" Grid.Column="0" SelectionMode="Extended"
                             HorizontalAlignment="Stretch" Margin="2,2,11,2" IsLoadOnDemandEnabled="True"
                             LoadOnDemand="radStructureTreeView_LoadOnDemand"
                             ExpanderStyle="{StaticResource ExpanderStyle}"
                             ItemContainerStyle="{StaticResource ItemContainerStyle}"
                             IsExpandOnSingleClickEnabled="False" ItemsSource="{Binding StructureDesignerList}"
                             ItemTemplate="{StaticResource NavigationTemplate}"
                             telerik:TreeViewSettings.DragDropExecutionMode="New"
                             >

        </telerik:RadTreeView>

        <Grid Grid.Row="0" Grid.Column="1" Name="gridEntities" HorizontalAlignment="Stretch" Margin="1,2,2,2">

            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"></ColumnDefinition>
            </Grid.ColumnDefinitions>

            <ListBox x:Name="listBox1" Grid.Row="0" Grid.Column="0" Margin="8" HorizontalAlignment="Stretch"
                     SelectionMode="Extended" Width="Auto" ItemsSource="{Binding EntityList}"
                     AllowDrop="True">
                <ListBox.ContextMenu>
                    <ContextMenu>
                        <MenuItem Header="Hide posted entities" Tag="Hide posted entities" IsCheckable="True" IsChecked="{Binding Path=IsHidePostedEntitiesChecked}"></MenuItem>
                    </ContextMenu>
                </ListBox.ContextMenu>
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Vertical">
                            <Label Name="lblSpacer1" Height="5"></Label>
                            <StackPanel Orientation="Horizontal">
                                <Image Grid.Column="1" Width="25" Height="16" Source="{Binding Path=Icon}" VerticalAlignment="Top"></Image>
                                <Label Content="" Width="1" Height="16"  ></Label>
                                <TextBlock Text="{Binding Description}" FontWeight="Bold" VerticalAlignment="Center" />
                            </StackPanel>
                            <Label Name="lblSpacer2" Height="5"></Label>
                        </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>

        </Grid>
    </Grid>
</UserControl>

0 个答案:

没有答案
相关问题