"wpf datatrigger enum binding" Code Answer's

You're definitely familiar with the best coding language C# that developers use to develop their projects and they get all their queries like "wpf datatrigger enum binding" answered properly. Developers are finding an appropriate answer about wpf datatrigger enum binding related to the C# coding language. By visiting this online portal developers get answers concerning C# codes question like wpf datatrigger enum binding. Enter your desired code related query in the search bar and get every piece of information about C# code related question on wpf datatrigger enum binding. 

wpf datatrigger enum binding

By SolsticeSolstice on Jun 29, 2020
//This example assumes enum and classes are in the same namespace
//If yours are not, use using statements and dot notation
//(Based on an answer from https://social.msdn.microsoft.com/Forums/vstudio/en-US/d22a01cc-91d7-4099-9f56-9707d475a7a8/textblock-text-set-based-on-enumeration?forum=wpf )

//Code-behind, C#
public enum EnumVals
{
	Excellent,
    Poor
}

public partial class MyUserControl : UserControl
    {
        private MyDataContext myDC;

        public MyUserControl()
        {
            InitializeComponent();
            myDC = new MyDataContext();
            this.DataContext = myDC;
        }
    }
//Helper class
public class MyDataContext : DependencyObject
    {
        public static readonly DependencyProperty CurStateProperty = DependencyProperty.Register("CurState", typeof(EnumVals), typeof(MyDataContext), new UIPropertyMetadata(EnumVals.Excellent));

        public EnumVals CurState
        {
            get => (EnumVals)GetValue(CurStateProperty);
            set => SetValue(CurStateProperty, value);
        }

    }


//XAML file snippet. Using the example of changing the fill of a polygon
//based on the value of the enum
<UserControl.Resources>
        <Style TargetType="{x:Type Polygon}">
            <Style.Triggers>
                <DataTrigger Binding="{Binding CurState}" Value="Excellent">
                    <Setter Property="Fill" Value="LimeGreen"/>
                </DataTrigger>
                <DataTrigger Binding="{Binding Path=CurState}" Value="Poor">
                    <Setter Property="Fill" Value="Red"/>
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </UserControl.Resources>

Source: social.msdn.microsoft.com

Add Comment

0

All those coders who are working on the C# based application and are stuck on wpf datatrigger enum binding can get a collection of related answers to their query. Programmers need to enter their query on wpf datatrigger enum binding related to C# code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about wpf datatrigger enum binding for the programmers working on C# code while coding their module. Coders are also allowed to rectify already present answers of wpf datatrigger enum binding while working on the C# language code. Developers can add up suggestions if they deem fit any other answer relating to "wpf datatrigger enum binding". Visit this developer's friendly online web community, CodeProZone, and get your queries like wpf datatrigger enum binding resolved professionally and stay updated to the latest C# updates. 

C# answers related to "wpf datatrigger enum binding"

View All C# queries

C# queries related to "wpf datatrigger enum binding"

wpf datatrigger enum binding wpf binding to static property in code behind c# wpf passwordbox binding wpf binding object get value wpf use enum description rad grid column wpf telerik enum initialize enum with another enum c# asp.net mvc table array binding arbitrary indices binding c# .net form binding why cant i skip index linq datatable group by binding datagridview + c# c# how to refresh your binding source c# wpf image source from resource programmatically wpf save file dialog visibility bound to radio button wpf aforge wpf webcam telerik wpf gridviewcombobox itemsource property on item c# wpf initializecomponent does not exist textbox gotfocus wpf page parent wpf allelrt box wpf CONTROLS DONT EXIST IN THE CURRENT CONTEXT AFTER REBUILD WPF C# Read csv file into wpf C# wpf itemscontrol in itemscontrol how to change text in richtextbox wpf wpf busy indicator c# wpf datagrid extra column wpf button to return to last window wpf get name of clicked element how to detected WindowCloseEvent in other window wpf telerik raddatepicker default date today wpf wpf label foreground in c# wpf bind image source to string c# wpf control to windw size wpf settings core wpf find child control by name wpf label content nullpointerexception wpf relativesource wpf how to focus on element PrintVisual wpf scale how to implement FluentValidation in wpf wpf clock conrt create a dialog in wpf wpf get dependency property in code start wpf application when windows start wpf icollectionview filter set margin programmatically wpf c# c# async in wpf wpf scoll to on new item datagrtid wpf textbox insert text at caret position wpf set button text color c# get value of object in enum c# enum variable set to nonthing enum get all values C# c# convert string to enum value how to retrive an enum string value instead of number in c# controller unity parse string to enum enum in method as argument c# unity how to check serialized enum unity how to check index of enum define enum c# C#: casting string to enum object RadioButton IsChecked mapped to ENum xmal

Browse Other Code Languages

CodeProZone