WPF C# Custom UserControl How To add a Property which accepts an Binding
I'm trying to design a CustomUserControl which consits of an TextEditor and a PopUp...
So the Popup control should be binded to a list... I called it BindingList. This Property should accept any types like ObservableCollection, List, Ienumerable for example(Collections)...
<my:CustomControl BindingList="{Binding Path=Collection}"
public IEnumerable<object> BindingList
{
get { return (IEnumerable<object>)GetValue(BindingListProp); }
set { SetValue(BindingListProp, value); }
}
The BindinglistProp
public s开发者_Python百科tatic readonly DependencyProperty BindingListProp = DependencyProperty.Register(??????
I have no clue how it should look like that it can accept a binding.
And how should i deal with the Collection which is passed? when it is of a type which i don`t know
like
class Person
{
private string _Name;
private string _forename;
public string Name
{
get { return _Name; }
set
{
_Name = value;
}
}
public string Forename
{
get { return _forename; }
set
{
_forename = value;
}
}
}
Thanks for any hints, tutorials or code snippets.
sincerely Mark
public IObservable<object> BindingList
{
get { return (IObservable<object>)base.GetValue(BindingListProperty); }
set { base.SetValue(BindingListProperty, value); }
}
public static DependencyProperty BindingListProperty =
DependencyProperty.Register(
"BindingList",
typeof(IObservable<object>),
typeof(CustomControl),
new PropertyMetadata(null));
Look to the CollectionViewSource.GetDefaultView to work with any collection in common way.
精彩评论