WPF TabItem Listbox dynamic binding
<p>Hy,</p>

<p>I would like to bind a color property to the background of a tab content:</p>

<pre><code>&lt;CollectionViewSource x:Key="MyCollectionViewSource" Source="{Binding QuickDialColl, Source={x:Static vm:QuickDialViewModel.Instance}}"&gt;
        &lt;CollectionViewSource.GroupDescriptions&gt;
            &lt;PropertyGroupDescription PropertyName="Category" /&gt;
        &lt;/CollectionViewSource.GroupDescriptions&gt;
    &lt;/CollectionViewSource&gt;
</code></pre>

<p>The QuickDialColl is an ObservableCollection of QuickDial Objects:</p>

<pre><code>    class QuickDial
{
    public string Name { get; set; }
    public string ToolTip { get; set; }
    public string Number { get; set; }
    public string Category { get; set; }
    public string CustomBackgroundColor { get; set; }
    public string TextColor { get; set; }

    public QuickDial()
    {
    }
}
</code></pre>

<p>
    
        
    </p>

<pre><code>&lt;TabControl ItemsSource="{Binding Groups, Source={StaticResource MyCollectionViewSource}}" SelectedIndex="0" &gt;

    &lt;TabControl.ItemTemplate&gt;
        &lt;DataTemplate&gt;
            &lt;TextBlock Text="{Binding Name}"/&gt;
        &lt;/DataTemplate&gt;
    &lt;/TabControl.ItemTemplate&gt;

    &lt;TabControl.ContentTemplate&gt;
        &lt;DataTemplate&gt;
            &lt;ListBox ItemsSource="{Binding Items}" 
                IsManipulationEnabled="False" 
                ScrollViewer.HorizontalScrollBarVisibility="Disabled" 
                HorizontalContentAlignment="Stretch" 
                VerticalContentAlignment="Stretch"&gt;

                &lt;ListBox.ItemsPanel&gt;
                    &lt;ItemsPanelTemplate&gt;
                        &lt;WrapPanel /&gt;
                    &lt;/ItemsPanelTemplate&gt;
                &lt;/ListBox.ItemsPanel&gt;

                &lt;ListBox.ItemTemplate&gt;
                    &lt;DataTemplate&gt;
                        &lt;Button Content="{Binding Name}" 
                            Background="{Binding CustomBackgroundColor,Converter={StaticResource HexToColorConverter}}"
                            ToolTip="{Binding ToolTip}"  
                            Width="130"
                            Margin="2,2,2,2" 
                             /&gt;

                    &lt;/DataTemplate&gt;
                &lt;/ListBox.ItemTemplate&gt;
            &lt;/ListBox&gt;
        &lt;/DataTemplate&gt;
    &lt;/TabControl.ContentTemplate&gt;

&lt;/TabControl&gt;
</code></pre>

<p></p>

<p>The dynamic binding is ok for the buttons with:</p>

<pre><code>Background="{Binding CustomBackgroundColor,Converter={StaticResource HexToColorConverter}}"
</code></pre>

<p>But I wish it works for the background of the tab contentpresenter (as all the buttons of the same category have the same background color).</p>

<p>I have tried to bind the wrappanel and the listbox bacground property with the same piece of code but it didn't work.</p>

<p>Here is the result I would like to get:</p>

<p><a href="http://i.stack.imgur.com/Vha5M.jpg" rel="nofollow">Tab Content background</a></p>

<p>I am surely missing the point...</p>

<p>Many thanks for you help.
Chris.</p>