WPF控件创作,公开要绑定的组件控件 [英] WPF Control authoring, expose a component control for binding
本文介绍了WPF控件创作,公开要绑定的组件控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
早上好,
我想在WPF中创建一个具有两个列表框的自定义控件,并允许用户直接绑定到xaml中这些列表框的ItemsSources.
任何人都可以对可能的方法提出任何建议吗?
我的预定用途如下
Morning all,
I want to create a custom control in WPF that has two list boxes and allow a user to bind directly to the ItemsSources of these list boxes in xaml.
Can anyone make any suggestions as to a possible approaches?
My intende usage would be as follows
<ControlLib:DualListControl LeftItemsSource={Binding SomeSource} RightItemsSource={Binding SomeOtherSource}/>
轻一点,我是WPF自定义控件的新手
Ta
Be gentle, I am new to WPF custom controls
Ta
推荐答案
好吧,最简单的方法是在控件内部命名控件(使用x:Name ="...")并公开ItemsSources作为属性,例如:
Well, the simplest way to do this would be to name the controls inside your control (using x:Name="...") and just expose the ItemsSources as properties, e.g.:
public IEnumerable MasterListView
{
get { return MasterList.ItemsSource; }
set { MasterList.ItemsSource = value; }
}
这篇关于WPF控件创作,公开要绑定的组件控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文