Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

How to bind label background color dynamically?

$
0
0

Hello,

I have a label inside a listbox and I tried to add background color dynamically.  but it is not worked for me. can someone help me? code as below,

<ListBox x:Name="libTest" ItemsSource="{Binding}" >
            <ListBox.ItemTemplate>
                <HierarchicalDataTemplate>
                    <StackPanel Orientation="Horizontal">

                            <Label  Background="{Binding TestColor}"  Height="30" Width="20"/>
                            <TextBlock  Text="{Binding TestName}"/>

                    </StackPanel>
                </HierarchicalDataTemplate>

            </ListBox.ItemTemplate>

        </ListBox>

Here  TestName binding correctly. But TestColor not working.


Viewing all articles
Browse latest Browse all 18858

Trending Articles