0

hey guys i have this converter :

 public class BudgetIndicatorConverter :IValueConverter
{

    public object Convert(object value, System.Type targetType,
                   object parameter, CultureInfo culture)
    {
        string Indicator = (string)value;
        Brush _brush = new SolidColorBrush();

        if (Indicator == "Green")
        {
            _brush = new SolidColorBrush(Colors.Green);
        }
        else if (Indicator == "Red")
        {
            _brush = new SolidColorBrush(Colors.Red);
        }

        return _brush;
    }


    public object ConvertBack(object value, System.Type targetType,
                  object parameter, CultureInfo culture)
    {
        return null;
    }


}

and here is my binding in the Xaml :

 <TextBlock TextWrapping="Wrap" Margin="260,120,0,70" FontSize="{StaticResource PhoneFontSizeNormal}"  Foreground="{Binding Data[0].BudgetIndicator, Converter={StaticResource budgetcolor}}" FontFamily="{StaticResource PhoneFontFamilyBold}" Text="{Binding Data[0].TOTAL, Converter={StaticResource convertcurrency}}" TextAlignment="Right"/>

now when i run this the textblock now shows nothing? i want to know if i can even bind 2 properties on the same control. like you can see in the text property i bind a currency with a converter and it worked.

could it be that my binding to "budgetindicator" could not be sending the right value through?

what i want to do is, once the currency is shown, it should either show the total as green or red, meanin in budget or over budget?

any tips or link will be appreciated

using visual studio 2012/c#/silverlight 5/windows phone8

if more stuff is needed to complete answer please let me know!

thanks in advance!

Arrie
  • 1,327
  • 5
  • 18
  • 39

2 Answers2

0

i want to know if i can even bind 2 properties on the same control

You can.

could it be that my binding to "budgetindicator" could not be sending the right value through?

That's the most likely cause.

any tips or link will be appreciated

Put a breakpoint in the BudgetIndicatorConverter.Convert method, to make sure that it is called. Then, execute the code step by step to understand what's going on. Also, check the output window to see if there is any error message related to the binding.

Kevin Gosse
  • 38,392
  • 3
  • 78
  • 94
0

Binding multiple properties is totally supported.

Here is what you should try:

  • Open the app with the debugger attached and look if there are binding errors in the Output window of Visual Studio
  • Place a breakpoint in your converter and check the values received
Olivier Payen
  • 15,198
  • 7
  • 41
  • 70