WPF: How to make styles in XAML conditional on a variable in your own C# code

前端 未结 2 1731
别跟我提以往
别跟我提以往 2020-12-22 01:54

WPF and XAML newbie here....

I need to tie a WPF Trigger or DataTrigger in XAML code into some C# code in a class other than the class of t

2条回答
  •  猫巷女王i
    2020-12-22 02:19

    Your C# code looks fine, and you already have the XML NameSpace declaration referencing your MyApplication namespace, so:

    You should just be able to access the enum value using the x:Static markup using the enum identifier as shown in this example (I like this example because it also shows how to use non-custom x:Static and how to do some tree traversal as well):

    
      
        
          
          
        
        
          
        
      
    
    

    In your case your Markup for your enum should be:

    Value="{x:Static my:SelectedReportType.DiagSummary}"

提交回复
热议问题