wpf - Populating ListBoxItem Background according to a Bool Member Object -
I have a boolean member class and I want to populate a Wpf ListBox with my class collection.
If my Boolean property is false, then I want the background of catalogs in a different color. Is it possible with xml? What is the best way to do this?
class MI {public bull mybool {get; Set;}} ... list & lt; MI & gt; Mycollection; // datacontax Here is a general general converter for booolans that allows you to type false for any kind of properties And specify some different values. Conversion (type of (bull), typef (object)) Public class boolean value conveyor: Ivail Convert {public object FalseValue {get; Set; } Public Object TrueValue {get; Set; } #region IValueConverter Member Convert Public Commodities (Object Value, Type TargetType, Object Parameter, CultureInfo Culture) {Return (bool) Value? this. Rabbit: this. Flowers; } Public Object Convertback (type object type, type target type, object parameter, cultureinfo culture) {return object.Equals (this.TrueValue, value)? right wrong; } #endregion} Use this as an example.
& lt; Solid codebrush x: key = "TrueBrush" color = "green" /> & Lt; Solid colored brush x: key = "FalseBrush" color = "Red" /> & Lt; Local: Boolean value converter x: key = "boolean background" TrueValue = "{static resource trubher}" fallawel = "{static resource fallbridge}" /> ... background = "{binding path = some property path. End with A. Boolean, converter = {static resource booleanbackband}}" />
Comments
Post a Comment