Fix CardGroup overwriting DataContext of its children

This commit is contained in:
Yusyuriv 2024-05-01 14:19:20 +06:00
parent 08687d63cb
commit fb6b1bb518
No known key found for this signature in database
GPG key ID: A91C52E6F73148E0
2 changed files with 3 additions and 3 deletions

View file

@ -26,6 +26,7 @@
</UserControl.Resources>
<Border Background="{DynamicResource Color00B}" BorderBrush="{DynamicResource Color03B}" BorderThickness="1"
CornerRadius="5">
<ItemsControl ItemsSource="{Binding Content}" ItemContainerStyleSelector="{StaticResource CardStyleSelector}" />
<ItemsControl ItemsSource="{Binding Content, RelativeSource={RelativeSource AncestorType=cc:CardGroup}}"
ItemContainerStyleSelector="{StaticResource CardStyleSelector}" />
</Border>
</UserControl>

View file

@ -13,13 +13,12 @@ public partial class CardGroup : UserControl
set { SetValue(ContentProperty, value); }
}
public static readonly DependencyProperty ContentProperty =
public static new readonly DependencyProperty ContentProperty =
DependencyProperty.Register(nameof(Content), typeof(ObservableCollection<Card>), typeof(CardGroup));
public CardGroup()
{
InitializeComponent();
DataContext = this;
Content = new ObservableCollection<Card>();
}
}