StringFormat is ignored

前端 未结 3 1753
执念已碎
执念已碎 2020-12-16 11:13


This is my binding (shortened, Command-Property is also bound)



        
3条回答
  •  温柔的废话
    2020-12-16 11:34

    use Binding Converter:

    public class CommandParamConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is string)
            {
                return string.Format("Key {0}", value);
            }
            return value;
        }
    
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
    

    Add it to Windows\UserControl resource:

    
        
    
    

    Refer it in Menu CommandParameter binding:

    
    

提交回复
热议问题