I'm learning WPF and I encountered the following problem:
I have an enum type in another namespace than my XAML:
public enum NodeType
{
Type_SYSTEM = 1, // System
Type_DB = 2, // Database
Type_ROOT = 512, // Root folder
Type_FOLDER = 1024, // Folder
}
in my XAML I'd like to trigger an image with an integer
<Image.Style>
<Style TargetType="{x:Type Image}">
<Style.Triggers>
<DataTrigger Binding="{Binding Type}" Value="{NodeType: }">
<Setter Property="Source" Value="/Images/DB.PNG"/>
</DataTrigger>
<DataTrigger Binding="{Binding Type}" Value="128">
<Setter Property="Source" Value="/Images/SERVER.PNG"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Image.Style>
Is there a way to get an integer value and compare it with an enum type directly in XAML code?
My enum is in namespace AnotherNamespace.Types
<DataTrigger Binding="{Binding IntegerType}" Value="MyEnumType.Type_DB">
<Setter Property="Source" Value="/Images/SERVER.PNG"/>
</DataTrigger>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…