`
Код: Выделить всё
`
Код: Выделить всё
public IEnumerable Sources
{
get { return (IEnumerable)GetValue(SourcesProperty); }
set { SetValue(SourcesProperty, value); }
}
public static readonly DependencyProperty SourcesProperty =
DependencyProperty.Register("Sources", typeof(IEnumerable),
typeof(MyUserControl), new PropertyMetadata(null));
Код: Выделить всё
public MyUserControl()
{
InitializeComponent();
_opt.ItemsSource = Sources;
}
Теперь я могу установить список строк в пользовательском элементе управления, но если я где-то использую пользовательский элемент управления, там я могу установить Itemsource и причину, по которой я создал IEnumerable.
Вот как я использую свой Пользовательский контроль,
Код: Выделить всё
public NewControl()
{
InitializeComponent();
_uc.Sources = MyListofString;
}
Подробнее здесь: https://stackoverflow.com/questions/792 ... s-expected
Мобильная версия