1

使用 Telerik RadTreeView 时,是否可以在 WPF 中自定义 DragPreview?

我已将其设置IsDragPreviewEnabled为 true,但正如您从图像中看到的那样,它所做的只是在按钮中显示命名空间,而不是预览被拖动的实际项目(在本例中是一行网格。

在此处输入图像描述

我很高兴不一定要显示我正在拖动的项目的预览 - 显示标准图像就足够了,只是为了给用户一些关于拖动正在发生的反馈。

有什么想法我能做到这一点吗?

谢谢

4

1 回答 1

0

您需要在窗口的资源中为相应的数据类型定义一个数据模板

例子

<Window x:Class="CSharpWPF.View"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow"
        xmlns:dto="clr-namespace:System.DataTransferObjects.ProcessMapItems">
    <Window.Resources>
        <DataTemplate DataType="{x:Type dto:ActivityItemDto}">
            <Image Source="itemImage.jpg" />
        </DataTemplate>
    </Window.Resources>
    ...
</Window>

这将在拖动容器中显示图像而不是标准文本。如果需要,您可能需要限制图像的大小。

以上只是您可能需要提供正确数据类型的示例,我根据问题中的屏幕做出了假设。

于 2014-06-25T03:02:10.243 回答