Click here to Skip to main content
15,886,919 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: Using negative height margin values to properly vertically align a control Pin
Stephen Holdorf23-Jul-16 4:50
Stephen Holdorf23-Jul-16 4:50 
GeneralRe: Using negative height margin values to properly vertically align a control Pin
Stephen Holdorf23-Jul-16 9:47
Stephen Holdorf23-Jul-16 9:47 
QuestionList Control Question Pin
Kevin Marois21-Jul-16 14:36
professionalKevin Marois21-Jul-16 14:36 
AnswerRe: List Control Question Pin
Gerry Schmitz22-Jul-16 11:18
mveGerry Schmitz22-Jul-16 11:18 
QuestionKeeping correct layout when browser is resized Pin
Stephen Holdorf17-Jul-16 3:37
Stephen Holdorf17-Jul-16 3:37 
AnswerRe: Keeping correct layout when browser is resized Pin
Gerry Schmitz18-Jul-16 6:19
mveGerry Schmitz18-Jul-16 6:19 
QuestionStyling a Drag and Drop Items behavior in a WPF ListView Pin
Kenneth Haugland13-Jul-16 5:43
mvaKenneth Haugland13-Jul-16 5:43 
QuestionShort way defining a property with the NotifyPropertyChanged() call Pin
Mc_Topaz9-Jul-16 9:26
Mc_Topaz9-Jul-16 9:26 
Here is a common way of having a ViewModel's property with the INotifyPropertyChanged interface:
C#
string text;
public string Text
{
    get { return text; }
    set
    {
        if (value != text)
        {
            text = value;
            NotifyPropertyChanged(nameof(Text));
        }
    }
}

This occupies one line for the member variable and twelve lines for the property.
In my ViewModel I have many properties and the code is getting very huge due to each property need the above body to include the NotifyPropertyChanged method and a member varible.

I prefer my properties to be defined in this way:
C#
public string Text { get; set; }

That property's body is just one line and I don't need to define a member variable.
But I cannot find out how to call the NotifyPropertyChanged method.

Is there a solution to short the body of the property and still have the call to the NotifyPropertyChanged method?

For instance:
* Having a property without the need of a member variable.
* Define the property as close as possible to: public string Text { get; set; }.
* Having the call to the NotifyPropertyChanged in the setter body.


Best regards,
/Steffe
AnswerRe: Short way defining a property with the NotifyPropertyChanged() call Pin
Mycroft Holmes9-Jul-16 11:35
professionalMycroft Holmes9-Jul-16 11:35 
AnswerRe: Short way defining a property with the NotifyPropertyChanged() call Pin
Mc_Topaz9-Jul-16 11:49
Mc_Topaz9-Jul-16 11:49 
AnswerRe: Short way defining a property with the NotifyPropertyChanged() call Pin
Super Lloyd10-Jul-16 14:31
Super Lloyd10-Jul-16 14:31 
AnswerRe: Short way defining a property with the NotifyPropertyChanged() call Pin
Pete O'Hanlon10-Jul-16 21:23
mvePete O'Hanlon10-Jul-16 21:23 
AnswerRe: Short way defining a property with the NotifyPropertyChanged() call Pin
Gerry Schmitz11-Jul-16 6:04
mveGerry Schmitz11-Jul-16 6:04 
AnswerRe: Short way defining a property with the NotifyPropertyChanged() call Pin
Kenneth Haugland13-Jul-16 4:12
mvaKenneth Haugland13-Jul-16 4:12 
GeneralRe: Short way defining a property with the NotifyPropertyChanged() call Pin
Mycroft Holmes13-Jul-16 12:54
professionalMycroft Holmes13-Jul-16 12:54 
QuestionAdd column sorting to a WPF grid Pin
Stephen Holdorf7-Jul-16 7:11
Stephen Holdorf7-Jul-16 7:11 
SuggestionRe: Add column sorting to a WPF grid Pin
Matt T Heffron7-Jul-16 7:39
professionalMatt T Heffron7-Jul-16 7:39 
GeneralRe: Add column sorting to a WPF grid Pin
Stephen Holdorf7-Jul-16 8:11
Stephen Holdorf7-Jul-16 8:11 
AnswerRe: Add column sorting to a WPF grid Pin
Gerry Schmitz8-Jul-16 6:52
mveGerry Schmitz8-Jul-16 6:52 
QuestionSingle Instance WPF App - Pass Params From Second Instance To First Instance Pin
Kevin Marois30-Jun-16 8:46
professionalKevin Marois30-Jun-16 8:46 
QuestionWPF empty tabbed dashboard example code Pin
Stephen Holdorf28-Jun-16 12:07
Stephen Holdorf28-Jun-16 12:07 
AnswerRe: WPF empty tabbed dashboard example code Pin
Pete O'Hanlon28-Jun-16 20:53
mvePete O'Hanlon28-Jun-16 20:53 
SuggestionRe: WPF empty tabbed dashboard example code Pin
Richard MacCutchan28-Jun-16 21:09
mveRichard MacCutchan28-Jun-16 21:09 
AnswerRe: WPF empty tabbed dashboard example code Pin
Gerry Schmitz1-Jul-16 5:47
mveGerry Schmitz1-Jul-16 5:47 
GeneralRe: WPF empty tabbed dashboard example code Pin
Stephen Holdorf6-Jul-16 10:11
Stephen Holdorf6-Jul-16 10:11 

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.