Click here to Skip to main content
16,004,924 members
Home / Discussions / WPF
   

WPF

 
QuestionWhich platform for a simple platform game to play by web rend erer ? Pin
EternallyConfuzzled31-May-12 22:28
EternallyConfuzzled31-May-12 22:28 
AnswerRe: Which platform for a simple platform game to play by web rend erer ? Pin
Abhinav S3-Jun-12 19:33
Abhinav S3-Jun-12 19:33 
QuestionComboBox MVVM Issue Pin
wasimsharp31-May-12 21:29
wasimsharp31-May-12 21:29 
AnswerRe: ComboBox MVVM Issue Pin
Alisaunder2-Jun-12 6:24
Alisaunder2-Jun-12 6:24 
QuestionWPF TreeView jumps up Pin
Mc_Topaz30-May-12 1:09
Mc_Topaz30-May-12 1:09 
AnswerRe: WPF TreeView jumps up Pin
Gerry Schmitz30-May-12 8:21
mveGerry Schmitz30-May-12 8:21 
QuestionSet webcam brightness in Silverlight Pin
ebrahim rajabloo29-May-12 19:28
ebrahim rajabloo29-May-12 19:28 
QuestionINotifyPropertyChanged on Interface class property? Pin
Adam_Dev29-May-12 1:02
Adam_Dev29-May-12 1:02 
Hi
I have a class called ErrorStatus. I am trying to use this class as a property in my interface. When a method is called and an error is thrown I want to populate this object.

I then call the methods of this interface from my viewmodel. I want to bind to properties of ErrorStatus from my xaml, through my viewmodel to the ErrorStatus property of the interface, but it doesn't seem to be working.

The error text isn't being displayed and the HasError isn't being retrieved. I suspect this is something to do with INotifyPropertyChanged and the scope.

I have cut the code down to the essentials.

I have the following class, ErrorStatus:
C#
public class ErrorStatus : INotifyPropertyChanged
{
        #region Properties
        bool _hasError = false;
        public bool HasError
        {
            get { return _hasError; }
            set 
            { 
                _hasError = value; 
                this.RaisePropertyChanged("HasError");
            }
        }

        string _text = String.Empty;
        public string Text
        {
            get { return _text; }
            set
            {
                _text = value;
                if (value != String.Empty)
                    HasError = true;

                this.RaisePropertyChanged("Text");
            }
        }
        #endregion

        public void Add(String error)
        {
            Text = error;
        }

#region INotifyPropertyChanged Interface
        public event PropertyChangedEventHandler PropertyChanged;
        protected virtual void RaisePropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
        #endregion
}


I also have the interface, IService:
C#
public interface IService : INotifyPropertyChanged
{
#region Properties
ErrorStatus ServiceStatus{get;}
#endregion

void TestMethod();
}


and the implementation, Service:
C#
public class MyService : IService
{
        private ErrorStatus _serviceStatus = new ErrorStatus();
        public ErrorStatus ServiceStatus
        {
            get { return _serviceStatus; }
            private set
            {
                if (_serviceStatus!= value)
                {
                    _serviceStatus= value;
                    RaisePropertyChanged("ServiceStatus");
                }
            }
        }

public void TestMethod()
{
  ServiceStatus.Add("TEST MESSAGE");
}

#region INotifyPropertyChanged Interface
        public event PropertyChangedEventHandler PropertyChanged;
        protected virtual void RaisePropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
        #endregion
}


Any help would be much appreciated, thanks.
AnswerRe: INotifyPropertyChanged on Interface class property? Pin
Pete O'Hanlon29-May-12 2:26
mvePete O'Hanlon29-May-12 2:26 
GeneralRe: INotifyPropertyChanged on Interface class property? Pin
Adam_Dev29-May-12 2:35
Adam_Dev29-May-12 2:35 
GeneralRe: INotifyPropertyChanged on Interface class property? Pin
Pete O'Hanlon29-May-12 2:49
mvePete O'Hanlon29-May-12 2:49 
GeneralRe: INotifyPropertyChanged on Interface class property? Pin
Adam_Dev29-May-12 2:51
Adam_Dev29-May-12 2:51 
GeneralRe: INotifyPropertyChanged on Interface class property? Pin
Pete O'Hanlon29-May-12 3:10
mvePete O'Hanlon29-May-12 3:10 
GeneralRe: INotifyPropertyChanged on Interface class property? Pin
Adam_Dev29-May-12 3:21
Adam_Dev29-May-12 3:21 
GeneralRe: INotifyPropertyChanged on Interface class property? Pin
Pete O'Hanlon29-May-12 3:30
mvePete O'Hanlon29-May-12 3:30 
GeneralRe: INotifyPropertyChanged on Interface class property? Pin
Adam_Dev29-May-12 3:46
Adam_Dev29-May-12 3:46 
GeneralRe: INotifyPropertyChanged on Interface class property? Pin
Pete O'Hanlon29-May-12 4:00
mvePete O'Hanlon29-May-12 4:00 
GeneralRe: INotifyPropertyChanged on Interface class property? Pin
Adam_Dev29-May-12 4:22
Adam_Dev29-May-12 4:22 
GeneralRe: INotifyPropertyChanged on Interface class property? Pin
Pete O'Hanlon29-May-12 22:03
mvePete O'Hanlon29-May-12 22:03 
GeneralRe: INotifyPropertyChanged on Interface class property? Pin
Adam_Dev29-May-12 22:10
Adam_Dev29-May-12 22:10 
GeneralRe: INotifyPropertyChanged on Interface class property? Pin
Pete O'Hanlon29-May-12 22:43
mvePete O'Hanlon29-May-12 22:43 
GeneralRe: INotifyPropertyChanged on Interface class property? Pin
Adam_Dev30-May-12 0:51
Adam_Dev30-May-12 0:51 
GeneralRe: INotifyPropertyChanged on Interface class property? Pin
Pete O'Hanlon30-May-12 1:17
mvePete O'Hanlon30-May-12 1:17 
Questionthe wpf added winform controls Pin
dengzn28-May-12 22:43
dengzn28-May-12 22:43 
AnswerRe: the wpf added winform controls Pin
Pete O'Hanlon28-May-12 23:01
mvePete O'Hanlon28-May-12 23:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.