ARTICLE AD BOX
Google hasn't found anything on this issue. Google AI offers a non-working solution, although it's compilable.
I have a UserControl. It contains an ItemsControl.
ItemsControl.ItemsSource = binding to my custom ObservableCollection.
I'm trying to insert my other UserControl into ItemsControl.ItemTemplate and bind its property MyText to the collection item's property ItemName.
It doesn't work - null.
Please help, I've been struggling for four days now.
xmlns:otherUC="clr-namespace:OtherUC" <ItemsControl Name="ListDevices" ItemsSource="{Binding Items}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <WrapPanel/> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ItemsControl.ItemTemplate> <DataTemplate> <Button> <otherUC:OtherUC Name="OtherUCItemName" MyText="{Binding ItemName}"/> </Button> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> public partial class OtherUC: UserControl { public static readonly StyledProperty<string> MyTextProperty = AvaloniaProperty.Register<OtherIC, string>(nameof(MyText)); public string MyText { get => GetValue(MyTextProperty); set => SetValue(MyTextProperty, value); } } public ObservableCollection<MyItem> Items { get => _items2; set { _items2 = value; OnPropertyChanged(); } } public record MyItem : INotifyPropertyChanged, IDisposable { public string ItemName { get => "Azaza"; set => OnPropertyChanged(); } }Explore related questions
See similar questions with these tags.
