0
XAML/WPFの新機能で、この奇妙な問題を抱えています。リストビューでのデータバインディング
私はDataSourceを設定したリストビューを持っています。 DataSourceは "CatalogPartRows"のarraylistです。コード内に列を作成します。私は自分のセルテンプレートを設定します(いくつかの列にはコンボボックスとチェックボックスがあります)。私の問題は、 "CatalogPartRow"クラスの中で、セルに設定する必要のある文字列を取り出す関数を呼び出す必要があることです。ここで
は、私が使用しようとしていますコードです:
// THIS DOES NOT WORK
//
ObjectDataProvider ODP = new ObjectDataProvider();
ODP.MethodName = "PropertyValueAsString";
ODP.MethodParameters.Add(PropertyName);
ODP.ObjectType = typeof(CatalogPartRow);
Binding DataBindingText = new Binding();
DataBindingText.Source = ODP;
// THIS WORKS
//
//String BindingPathText = /*NOXLATE*/"PropertyValues[" + CPR.IndexOf(PropertyName) + /*NOXLATE*/"]";
//Binding DataBindingText = new Binding(BindingPathText);
FrameworkElementFactory TextBlockElement = new FrameworkElementFactory(typeof(TextBlock));
TextBlockElement.SetBinding(TextBlock.TextProperty, DataBindingText);
FrameworkElementFactory PropertyColumnElement = new FrameworkElementFactory(typeof(Grid));
PropertyColumnElement.AppendChild(TextBlockElement);
DataTemplate DT = new DataTemplate();
DT.VisualTree = PropertyColumnElement;
GVC.CellTemplate = DT;
は正しい私のアプローチですか?
CPR = CatalogPartRow
GVC = GridViewColumn
おかげで、 ラジ。