x:Static in UWP XAML

后端 未结 4 1105
无人共我
无人共我 2020-12-08 20:09

An app I\'m working on requires a ConverterParameter to be an enum. For this, the regular way to do would be:

{Binding whatever, 
    Converter={StaticResour         


        
4条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-08 20:30

    This is an answer utilizing resources and without Converters:

    View:

    
      
        
            EnumNamedConstant
        
    
        

    ViewModel

        public RelayCommand DoSomethingCommand { get; }
    
        public SomeViewModel()
        {
            DoSomethingCommand = new RelayCommand(DoSomethingCommandAction);
        }
    
        private void DoSomethingCommandAction(EnumType _enumNameConstant)
        {
         // Logic
         .........................
        }
    

提交回复
热议问题