0
我有這樣的代碼:的XAML轉換器
Color color = GetMyColor();
string s = @"<DataTemplate xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""><StackPanel Background=""" + color + "\" ><TextBlock Text=\"{Binding Label}\" HorizontalAlignment=\"Center\" /></StackPanel></DataTemplate>";
var MyObject.Template = (DataTemplate)XamlReader.Load(s);
而且我想轉換器添加到我的結合,somethind這樣的:
Color color = GetMyColor();
string s = @"<DataTemplate xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""><StackPanel Background=""" + color + "\" ><TextBlock Text=\"{Binding Converter={StaticResource NumberConverter}}\" HorizontalAlignment=\"Center\" /></StackPanel></DataTemplate>";
var MyObject.Template = (DataTemplate)XamlReader.Load(s);
但是,這是行不通的,因爲我需要添加我認爲的轉換器的名稱空間。
我該怎麼做?
感謝