Bind Icon depending on Enum in WPF Treeview
- by phenevo
Hi,
I have at treeeview TextBox, and I want convert my Enum:
<TextBlock TextAlignment="Justify" VerticalAlignment="Center" Text="{Binding Path=AcceptationStatusGlobalFlag}" />
public enum AcceptationStatusGlobalFlag
{
NotReady = 0,
Ready = 1,
AcceptedByAdmin=2
}
To Icons. There will be 3 icons, let say ready.jpg, notready.jpg and AcceptedByAdmin.jpg
Country and Region has pool AcceptationStatusGlobalFlag and on both I want to display this enum/Icon
<TreeView Name="structureTree" SelectedItemChanged="structureTree_SelectedItemChanged" Grid.Row="0" Grid.Column="0" ItemsSource="{Binding}" Height="413" ScrollViewer.VerticalScrollBarVisibility="Visible" ScrollViewer.HorizontalScrollBarVisibility="Visible" Width="Auto" PreviewMouseRightButtonUp="structureTree_PreviewMouseRightButtonUp" FontFamily="Verdana" FontSize="12">
<TreeView.Resources>
<HierarchicalDataTemplate DataType="{x:Type ServiceMy:Country}"
ItemsSource="{Binding Path=ListOfRegions}">
<StackPanel Orientation="Horizontal">
<TextBlock TextAlignment="Justify" VerticalAlignment="Center" Text="{Binding Path=Name}"/>
<TextBlock TextAlignment="Justify" VerticalAlignment="Center" Text=" H:"/>
<TextBlock TextAlignment="Justify" VerticalAlignment="Center" Text="{Binding Path=NumberOfHotels}"/>
<TextBlock TextAlignment="Justify" VerticalAlignment="Center" Text=" "/>
<TextBlock TextAlignment="Justify" VerticalAlignment="Center" Text=" FG:"/>
<TextBlock TextAlignment="Justify" VerticalAlignment="Center" Text="{Binding Path=AcceptationStatusGlobalFlag}" />
<!--<Button Name="BTNAddRegion" Height="20" Content="+" Click="BTNAddRegion_Click"></Button>-->
</StackPanel>
</HierarchicalDataTemplate>
<HierarchicalDataTemplate DataType="{x:Type ServiceMy:Region}"
ItemsSource="{Binding Path=ListOfProvinces}">
<StackPanel Orientation="Horizontal">
<TextBlock TextAlignment="Justify" VerticalAlignment="Center" Text="{Binding Path=Name}"/>
<TextBlock TextAlignment="Justify" VerticalAlignment="Center" Text=" H:"/>
<TextBlock TextAlignment="Justify" VerticalAlignment="Center" Text="{Binding Path=NumberOfHotels}"/>
<TextBlock TextAlignment="Justify" VerticalAlignment="Center" Text=" "/>
<!--<Button Name="BTNAddProvince" Height="20" Content="+" Click="BTNAddProvince_Click"></Button>-->
</StackPanel>
</DataTemplate>
</TreeView.Resources>
</TreeView>
</GroupBox>
</StackPanel>
</Grid>