I have a style to a custom control that inherits from combobox that I can’t modify. Inside this style, there’s a DataGrid control that takes in a ItemsSource, the DataGrid also has an x:Name that needs to get referenced in code somewhere, probably due to the event.
So basically
<Style x:Key="ComboBoxStyle" TargetType="ComboBox">
<Setter Property="Template">
<Setter.Value>
... A whole bunch of other stuff.
<xcdg:DataGridControl
x:Name="CustomItemOneGrid"
ItemsSource="{Binding Source={StaticResource CustomItemOne_DataSource}}"
SelectionChanged="CustomItemOneGrid_SelectionChanged">
My problem here is that CustomItemOne_DataSource, well there’s 3 times I’ll use this control and well 3 datasources. Also, the selection changed event I need to subscribe to also. Is there a way to keep this in a style I can use across all three controls, but still have different Event and ItemsSource?
Define attached properties for the items that can change that are not defined by the
ComboBoxclass (eg.GridItemsSource). Then bind to those attached properties in your template. Much like I discuss here.