Hallo,
Ich hoffe der Titel ist in Ordnung - das Problem ist (für mich) schwer in nur ein paar Worte zu fassen.
Ansonsten bitte ich um Vorschläge für einen besseren Titel
Ich bin ein ziemlicher Neuling was C# aber vor allem auch WPF angeht und habe eine Frage zu Bindings.
Auf meinem Formular habe ich eine ListView. Im Code (nicht im xaml) weise ich der ListView zur Laufzeit als Datacontext eine DataView zu und erstelle ein CellTemplate dafür.
Ich möchte nun dass alle Zeilen wo die RowError-Property des entsprechenden DataRow-Objekts nicht leer ist fett sind.
Dafür wollte ich die FontWeight-Property des TextBlocks mit einem Converter an die RowError-Property binden.
(Der Converter konvertiert alles != "" in FontWeights.Bold, ansonsten FontWeights.Normal)
C#-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22:
| DataView dtv = Datatable.DefaultView; Binding bind = new Binding(); listview.SetBinding(ListView.ItemsSourceProperty, bind); listview.DataContext = dtv;
FrameworkElementFactory txtBlock= new FrameworkElementFactory(typeof(TextBlock)); txtBlock.SetBinding(TextBlock.TextProperty, new Binding("Wert"));
Binding boldBind = new Binding(); boldBind.Converter = new WertToFontWeightConverter(); boldBind.Path = new PropertyPath("???"); DataTemplate tpl = new DataTemplate(); tpl.VisualTree = txtBlock;
((GridView)listview.View).Columns[0].CellTemplate = tpl; |
Es würde mich freuen wenn mir da jmd. helfen könnte oder auch ggf. gute Alternativen zeigen könnte.
Crosspost:
www.delphipraxis.net...den.html#post1313215