I've got a custom ItemsControl
in my project and I'm trying to write a style for it that combines a static list of items with a list of items on a Dependency Property on the control itself.
Here is the respective XAML in my Resource Dictionary:
<x:Array Type="{x:Type System:Object}" x:Key="Static_CloudItems">
<Button>One</Button>
<Button>Two</Button>
<Button>Three</Button>
</x:Array>
<Style TargetType="{x:Type ControlsBase:CloudControl}" x:Key="BasicCloudStyle">
<Setter Property="ItemsSource">
<Setter.Value>
<CompositeCollection>
<CollectionContainer Collection="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ControlsBase:CloudControl}}, Path=CloudItems}" />
<CollectionContainer Collection="{StaticResource Static_CloudItems}" />
</CompositeCollection>
</Setter.Value>
</Setter>
</Style>
And then the respective code in my controls/windows/whatever:
<ControlsBase:CloudControl Style="{DynamicResource BasicCloudStyle}">
<ControlsBase:CloudControl.CloudItems>
<x:Array Type="{x:Type System:Object}">
<Button>Four</Button>
<Button>Five</Button>
</x:Array>
</ControlsBase:CloudControl.CloudItems>
</ControlsBase:CloudControl>
The Idea is that the style should combine the static elements with whatever elements are defined on the per-instance edition of the control.
My issue is, The binding above does not work (and I've realized why too!) So I need a way to be able to bind to the style's parent, but since the setter isn't in the visual/logical tree, just a property I'm a bit puzzled about how to proceed.