无法将我的自定义ScatterViewItem对象拖放到库容器中 [英] Can't Drag-Drop my custom ScatterViewItem object into a Library Container

查看:70
本文介绍了无法将我的自定义ScatterViewItem对象拖放到库容器中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于该项目基于Microsoft Surface,我正在使用SurfaceDragDrop,我在这里会问这个问题。虽然,我怀疑这更像是一个数据绑定问题,它可以进入WPF论坛。如果您认为这不合适,请告诉我。


我有自己的自定义类MyNode,它有自己的xaml,代码隐藏和它的小元素菜单,继承自ScatterViewItem(svi) )。我想将MyNode从ScatterView移动到两个库容器。


在视觉上,MyNode看起来应该是相同的,无论它是浮动在ScatterView还是库容器中。但是,如果不可能这样做,我只希望Library容器显示MyNode的textName和BitmapImage。我在库容器中有数据
模板信息,显示在下面。


不幸的是,我似乎无法使用MyNode执行此操作。当我将MyNode从ScatterView拖放到库容器时,我在库容器中看到一个半透明的黑色方块,没有数据绑定信息。当我尝试将MyNode
从Library容器拖放到ScatterView时,程序抛出一个null异常,说它的键不能为null。我已经半成功地移动了BitmapImages,但没有使用我自己的具有自己的xaml的类对象。


因此,从ScatterView到库的拖放MyNode并不成功容器,反之亦然。当涉及到继承SVI内部库容器的SVI / Classes时,是否有任何数据绑定建议?具体来说,这是我的
两个怀疑:


  1. 数据库容器的数据绑定是不对的,尽管我查看了其他文档。 MyNode具有公共属性,imgSource和textName。以下是我的所作所为:

 

 
< DataTemplate x:Key = " LibraryItemTemplate " DataType = " MyNode " >
< StackPanel Orientation = < span style ="color:Black;">" Vertical " < span style ="color:Red;">宽度 = " 70 " 高度 = " 60 " >
< Viewbox Stretch = " 制服 " >
< span style ="color:Blue;">< 图像 来源 < span style ="color:Blue;"> = " {Binding imgSource} " 宽度 = " 50 " 高度 = " 50 " ; />
< / Viewbox >
< TextBlock 文字 = < span style ="color:Black;">" {Binding textName} " 前景 = " 白色 " />
< / StackPanel >
< / DataTemplate >

解决方案

请检查Lbraray容器是否设置为仅接受MyNode类型。如果我记得很好,请按顺序b $ b要做这样的操作,你的库容器中的接受类型必须被定义为你的mynode。


希望它有所帮助


serge


Since the project is based off the Microsoft Surface, and I'm using SurfaceDragDrop, I'll ask this here. Though, I suspect it's more of a data binding problem, where it could go in the WPF forum. Please let me know if you think this is inappropriate here.

I have my own custom class, MyNode, with its own xaml, code-behind and its little elementMenu, inherited from ScatterViewItem(svi). I want to move MyNode from a ScatterView to two Library Containers.

Visually, MyNode should look the same regardless of whether it's floating in the ScatterView or in a library container. But, in case it's not possible to do that, I just want the Library container to show a MyNode's textName and BitmapImage. I have data template information in the library container, shown a little bit below.

Unfortunately, I can't seem to do any of this with my MyNode. When I drop a MyNode from ScatterView to a Library Container, I see a semi-transparent black square in the Library Container, with no data binding information. When I try to drag-drop that MyNode from the Library container to the ScatterView, the program throws a null exception, saying that its key can't be null. I have been semi-successful to move BitmapImages around, but not with my own class objects that have it's own xaml.

So, dragging and dropping MyNode has not been successful, from ScatterView to Library container and vice-versa. Does anyone have any data binding advice when it comes to SVI's/Classes that inherit SVI's inside Library Containers? Specifically, here are my two suspicions:

  1. Data Binding for the Library container isn't right, though I looked over other documentation for this. MyNode has public properties, imgSource and textName. Below is what I did:

 

    <DataTemplate x:Key="LibraryItemTemplate" DataType="MyNode">
      <StackPanel Orientation="Vertical" Width="70" Height="60">
        <Viewbox Stretch="Uniform">
          <Image Source="{Binding imgSource}" Width="50" Height="50" />
        </Viewbox>
        <TextBlock Text="{Binding textName}" Foreground="White" />
      </StackPanel>
    </DataTemplate>

解决方案

have you check that the Lbraray container is set to accept only type of MyNode.
if I remeber well, in order to do such operation, accepted type in your library container items must be defined as your mynode.

hope it helps

serge


这篇关于无法将我的自定义ScatterViewItem对象拖放到库容器中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆