从Item DataTemplate数据绑定到GridView [英] Databinding to GridView from Item DataTemplate

查看:67
本文介绍了从Item DataTemplate数据绑定到GridView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个< GridView>定义如下:

I have a <GridView> that is defined like this:

< GridView

Tag =" {Binding ShowImage}"

ItemTemplate =" {StaticResource MyItemTemplate}"

....
$
< / GridView>

<GridView
Tag="{Binding ShowImage}"
ItemTemplate="{StaticResource MyItemTemplate}"
....
</GridView>

DataTemplate包含:

The DataTemplate contains this:

< DataTemplate x:Key =" MyItemTemplate">

...


< Image Visibility =" {Binding Path = Tag,RelativeSource = {RelativeSource TemplatedParent},Converter = {...} />

< / DataTemplate>

<DataTemplate x:Key="MyItemTemplate">
...
<Image Visibility="{Binding Path=Tag, RelativeSource={RelativeSource TemplatedParent}, Converter={...} />
</DataTemplate>

ShowImage绑定到我的ViewModel,我基本上试图将它绑定到DataTemplate内Image的Visibility属性。  然而,RelativeSource似乎没有工作(或者更准确地说我称错了!) 我正在尝试
来更改GridView中每个项目的此Image元素的可见性。

ShowImage is bound to my ViewModel, and I am basically trying to bind that to the Visibility property of the Image inside the DataTemplate.  However RelativeSource doesn't seem to be working (or more accurately I am calling it wrong!)  I am trying to change the visibility of this Image element for every item in the GridView.

我希望这是有道理的,任何帮助都会受到赞赏。

I hope this makes sense, any help would be appreciated.

谢谢,

Bob  

Thanks,
Bob 

推荐答案

可能与elementname属性为绑定?
maybe with elementname attribute of an binding?


这篇关于从Item DataTemplate数据绑定到GridView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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