I have some colors for my Layer
objects that are shown in a TreeView
. Right now I use something like this:
<GridViewColumn Width="300">
<GridViewColumnHeader Content="Layers" />
<GridViewColumn.CellTemplate>
<DataTemplate>
<StackPanel MouseLeftButtonDown="Layers_MouseLeftButtonDown" Orientation="Horizontal">
<Image Width="15"
Height="15"
Source="{Binding ImageFromColor}" />
<TextBlock Text="{Binding Name}" />
</StackPanel>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
The original color values are gonna be accessed (binded) from the Layer
itself, so like:
layer.Color
of type System.Drawing.Color
. But I can change the type to be something else if it would make things easier.
What's the best way to do this in terms of performance and elegance?
I will have a couple thousand TreeView
items it that makes a difference.