Is there a way to declare a tuple in xaml so I can u开发者_C百科se it as a converterparameter?
Not directly.
There are some interesting solutions to similar questions:
- Create a Dictionary in xaml?
- Adding SortedList or Dictionary<int, string> to ResourceDictionary
Generally, you will have to create your own type that is non-generic and use it instead.
EXAMPLE
For:
Tuple<string, int, double>
You could create a class:
namespace Models
{
    class MyData
    {
        public MyString { get; set; }
        public MyInt { get; set; }
        public MyDouble { get; set; }
    }
}
Then add a namespace to XAML:
xmlns:models="clr-namespace:Models"
Then create your instance as needed:
<models:MyData MyString="someString" MyInt="123" MyDouble="0.1" />
You don't need to declare it in XAML. You can use x:Static to assign a ConverterParameter declared in code:
<TextBlock Text="{Binding Converter={x:Static local:MyConverter.Default}, ConverterParameter={x:Static local:MySettings.Name}}" />
And what you're accessing just needs to be static:
public static class MySettings
{
    public static string Name
    {
        get { return "Test"; }
    }
}
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论