Refreshing a binding that uses a value converter

Posted by Hadi Eskandari on Stack Overflow See other posts from Stack Overflow or by Hadi Eskandari
Published on 2010-03-18T10:54:36Z Indexed on 2010/03/18 11:11 UTC
Read the original article Hit count: 302

Filed under:
|
|

I have a WPF UI that is bound to an object. I'm using a ValueConverter to convert a property to a specific image by a business rule:


    public class ProposalStateImageConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var proposal = value as Proposal;
            var basePath = "pack://application:,,,/ePub.Content;component/Images/General/Flag_{0}.png";
            string imagePath;

            if(proposal.Invoice != null)
            {
                imagePath = string.Format(basePath, "Good");
            }
            else
            {
                imagePath = string.Format(basePath, "Warning");
            }

            var uri = new Uri(imagePath);
            var src = uri.GetImageSource(); //Extention method

            return src;
        }
    }

It is working fine, but later, when the object's state changes, I want to refresh the image and make the value converter reevaluate. How is this possible?

© Stack Overflow or respective owner

Related posts about wpf

Related posts about binding