ItemsControl子级是ContentPresenter,不是我的UserControl [英] ItemsControl children are ContentPresenter, not my UserControl

查看:87
本文介绍了ItemsControl子级是ContentPresenter,不是我的UserControl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在ItemsSource模式下有一个ItemsControl.当我将一个项目添加到源中时,将根据一个数据模板创建一个用户控件,该数据模板与我刚添加的项目相对应. ItemsControl使用画布作为它的ItemsPanel.问题是,当我检查代码时,发现画布的子级是ContentPresenters,而不是UserControl.我希望能够访问画布中的特定UserControl,以便可以使用它的功能.有人可以帮我吗?

I have an ItemsControl in ItemsSource mode. When I add an item to the source, a usercontrol is created from a datatemplate that corresponds to the item I just added. The ItemsControl uses a canvas as it''s ItemsPanel. The problem is that when I inspect my code, I find that the children of my canvas are ContentPresenters, not my UserControl. I would like to be able to access the particular UserControl in the canvas so I can use it''s functionality. Can anyone help me with this?

推荐答案

你好,

您可以访问ContentPresenter的"Content"属性来获取内容:)!

希望有帮助.
Hello,

You can access the "Content" property of the ContentPresenter to get your content :) !

Hope this help.


这篇关于ItemsControl子级是ContentPresenter,不是我的UserControl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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