動的プロパティの代わりに、名前付き値のディクショナリを使用します。
ディクショナリコンバータを使用して、ディクショナリ内の特定のエントリにバインドできます(コンバータのパラメータ値をキーとして使用)。このリンクから以下のコード
public class DictionaryItemConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var dict = value as Dictionary<string, string>;
if (dict != null)
{
return dict[parameter as string];
}
throw new NotImplementedException();
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
コードを介してグリッドに列を追加する場合は、正しいコンバーターと名前コンバーターパラメーターを使用してバインディングを作成する必要があります。