У меня есть UserControl. Он содержит ItemsControl. ItemsControl.ItemsSource привязывается к моей пользовательской ObservableCollection. Я пытаюсь вставить другой свой UserControl в ItemsControl.ItemTemplate и привязать его свойство MyText к свойству ItemName элемента коллекции.
Это не работает. ПустойotherUC со значениями изotherUCViewModel генерируется, но привязка не произошла.
xmlns:otherUC="clr-namespace:OtherUC"
public partial class OtherUC: UserControl
{
public static StyledProperty MyTextProperty = AvaloniaProperty.Register(nameof(MyText));
public string MyText
{
get => GetValue(MyTextProperty);
set => SetValue(MyTextProperty, value);
}
}
public ObservableCollection Items
{
get => _items2;
set
{
_items2 = value;
OnPropertyChanged();
}
}
public record MyItem : INotifyPropertyChanged, IDisposable
{
public string ItemName
{
get => "Azaza";
set => OnPropertyChanged();
}
}
У меня есть UserControl. Он содержит ItemsControl. ItemsControl.ItemsSource привязывается к моей пользовательской ObservableCollection. Я пытаюсь вставить другой свой UserControl в ItemsControl.ItemTemplate и привязать его свойство MyText к свойству ItemName элемента коллекции. Это не работает. ПустойotherUC со значениями изotherUCViewModel генерируется, но привязка не произошла. [code]xmlns:otherUC="clr-namespace:OtherUC"
public partial class OtherUC: UserControl { public static StyledProperty MyTextProperty = AvaloniaProperty.Register(nameof(MyText));
public string MyText { get => GetValue(MyTextProperty); set => SetValue(MyTextProperty, value); } }
public ObservableCollection Items { get => _items2; set { _items2 = value; OnPropertyChanged(); } }
public record MyItem : INotifyPropertyChanged, IDisposable { public string ItemName { get => "Azaza"; set => OnPropertyChanged(); } } [/code] Пример выполнения