I'm sorry to ask a really basic question but am working on having a converter in code behind xaml page. This converter would change a background color based on the value in a data element. I know the data element I want is available because when I break debugging at the execution of the converter, the value I want is in "value". From the immediate window in VS2013 I display the contents of "value" and get this:
{VehicleTracks.ViewModels.vehicleViewModel}
base: {VehicleTracks.ViewModels.vehicleViewModel}
purchasedate: {7/14/2014 12:00:00 AM}
PurchaseDate: {7/14/2014 12:00:00 AM}
VehColor: "Chartreuse"
VehicleBitMap: null
vehiclebitmap: null
vehiclecolor: "Chartreuse"
vehiclemodel: "Algo"
vehmake: "Test Vehicle"
VehMake: "Test Vehicle"
VehType: "Auto"
vehtype: "Auto"
vehyear: "1908"
VehYear: "1908"
The element "VehType" is the one I want. I want to change background color based on its value. You see that it is set to "Auto" in this instance. Here is the applicable part of my converter code:
public sealed class ValueToColorConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
SolidColorBrush blueBrush = new SolidColorBrush(Windows.UI.Colors.Blue);
if (value[VehType] == "Auto")
{
return blueBrush;
}
else
{
SolidColorBrush greenBrush = new SolidColorBrush(Windows.UI.Colors.Green);
return greenBrush;
}
}
The reference I now have there, value[VehType] is not getting it. What do I need there?