WPF Textblock Convert Issue

Posted by deep on Stack Overflow See other posts from Stack Overflow or by deep
Published on 2010-06-02T06:13:54Z Indexed on 2010/06/02 6:53 UTC
Read the original article Hit count: 338

Filed under:
|
|

am usina text block in usercontrol, but am sending value to textblock from other form, when i pass some value it viewed in textblock, but i need to convert the number to text. so i used converter in textblock. but its not working

 <TextBlock Height="21" Name="txtStatus" Width="65" Background="Bisque" TextAlignment="Center" Text="{Binding Path=hM1,Converter={StaticResource TextConvert},Mode=OneWay}"/>

converter class

class TextConvert : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {

        if (value != null)
        {
            if (value.ToString() == "1")
            {
                return value = "Good";

            }
            if (value.ToString() == "0")
            {
                return value = "NIL";

            }

       }
        return value = "";
    }
    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        return (string)value;
    }

}

is it right? whats wrong in it??

© Stack Overflow or respective owner

Related posts about wpf

Related posts about convert