Sweet Zombie Jesus. Don't write your ViewModels like that - use
http://code.google.com/p/notifypropertyweaver/ and maintain your sanity.

That ViewModel in the blog post becomes:

public class MainModel : INotifyPropertyChanged
{

    public string Radio1 { get; set; }

    [AlsoNotifyFor("TextValue")]
    public bool Radio1IsCheck { get; set; }

    public bool Radio1IsCheck { get; set; }
        public bool Radio2IsCheck
        {
            get { return this._radio2IsCheck; }
            set
            {
                this._radio2IsCheck = value;
                this.OnPropertyChanged("Radio1IsCheck");
                this.OnPropertyChanged("TextValue");
            }
        }

        private string _radio2 = "Radio2";
        public string Radio2
        {
            get { return this._radio2; }
            set
            {
                this._radio2 = value;
                this.OnPropertyChanged("Radio2");
            }
        }

        public string TextValue
        {
            get
            {
                string selected = this.Radio1IsCheck ? this.Radio1 :
this.Radio2;
                return string.Format("You have selected {0}", selected);
            }
        }
        #region INotifyPropertyChanged Members

        private void OnPropertyChanged(string propName)
        {
            if (this.PropertyChanged != null)
                this.PropertyChanged(this, new
PropertyChangedEventArgs(propName));
        }
        public event PropertyChangedEventHandler PropertyChanged;

        #endregion
    }



On Thu, Nov 24, 2011 at 5:13 PM, Patrick Klug <[email protected]> wrote:

> typically WPF. for the simplest thing you need a 100 LOC viewmodel, a
> bunch of XAML bindings. work around one or more bugs with the framework and
> (often but not in this case) create a bunch of valueconverters. - and of
> course you can also do it in three other ways each of which have different
> advantages/drawbacks
>
> makes you wonder how much time databinding really saves when you can
> hardly bind to anything but a specifically created viewmodel anyway.
> #grumpydeveloper
>
> On Thu, Nov 24, 2011 at 4:06 PM, Grant Molloy <[email protected]> wrote:
>
>>
>> Oops.. typo..
>>
>> www.abhisheksur.com/2011/03/issue-with-radiobuttons-and-binding-for.html
>> On 24/11/2011 4:03 PM, "Kirsten Greed" <[email protected]> wrote:
>>
>>>  Thanks Grant****
>>>
>>> However the link seems not to work****
>>>
>>> Am I missing something?****
>>>
>>>  ****
>>>   ------------------------------
>>>
>>> *From:* [email protected] [mailto:
>>> [email protected]] *On Behalf Of *Grant Molloy
>>> *Sent:* Thursday, 24 November 2011 4:58 PM
>>> *To:* ozWPF
>>> *Subject:* RE: Getting up to speed in wpf****
>>>
>>> ** **
>>>
>>> This example shows full xaml file, which may assist..
>>> www.abhishesur.com/2011/03/issue-with-radiobuttons-and-binding-for.html*
>>> ***
>>>
>>> On 24/11/2011 3:54 PM, "Grant Molloy" <[email protected]> wrote:****
>>>
>>> Agree that partial samples don't help that much!****
>>>
>>> I think it can be anywhere, but you need to bring it into scope by
>>> including it in your xaml file..  that's what the resource declaration is
>>> doing.****
>>>
>>> On 24/11/2011 3:44 PM, "Kirsten Greed" <[email protected]> wrote:*
>>> ***
>>>
>>> I had been looking at that tutorial – but I couldn’t figure out where he
>>> wants me to put EnumMatchToBooleanConverter  it doesn’t seem to find it in
>>> the code behind class****
>>>
>>>  ****
>>>
>>>  ****
>>>   ------------------------------
>>>
>>> *From:* [email protected] [mailto:
>>> [email protected]] *On Behalf Of *Grant Molloy
>>> *Sent:* Thursday, 24 November 2011 4:34 PM
>>> *To:* ozWPF
>>> *Subject:* RE: Getting up to speed in wpf****
>>>
>>>  ****
>>>
>>> Www.wpftutorial.net/RadioButton.html****
>>>
>>> On 24/11/2011 3:31 PM, "Kirsten Greed" <[email protected]> wrote:*
>>> ***
>>>
>>> Yes but how about binding data to radio buttons?****
>>>
>>>  ****
>>>   ------------------------------
>>>
>>> *From:* [email protected] [mailto:
>>> [email protected]] *On Behalf Of *Scott Barnes
>>> *Sent:* Thursday, 24 November 2011 3:41 PM
>>> *To:* ozWPF
>>> *Subject:* Re: Getting up to speed in wpf****
>>>
>>>  ****
>>>
>>> That and in WPF you can put pink/yellow rainbow gradients everywhere...*
>>> ***
>>>
>>>  ****
>>>
>>>  ****
>>>
>>> Why are you looking at me like that... don't judge me.****
>>>
>>>  ****
>>>
>>>
>>> ---
>>> Regards,
>>> Scott Barnes
>>> http://www.riagenic.com****
>>>
>>> On Thu, Nov 24, 2011 at 2:40 PM, Grant Molloy <[email protected]>
>>> wrote:****
>>>
>>> Patrick,
>>> Do you honestly believe that data centric app are better in winforms?
>>> I would much rather use wpf for data centric app over winforms. The
>>> binding model in wpf is very strong and, I think, makes life easier.****
>>>
>>> On 24/11/2011 2:29 PM, "Patrick Klug" <[email protected]> wrote:****
>>>
>>>
>>> _______________________________________________
>>> ozwpf mailing list
>>> [email protected]
>>> http://prdlxvm0001.codify.net/mailman/listinfo/ozwpf****
>>>
>>>  ****
>>>
>>>
>>> _______________________________________________
>>> ozwpf mailing list
>>> [email protected]
>>> http://prdlxvm0001.codify.net/mailman/listinfo/ozwpf****
>>>
>>>
>>> _______________________________________________
>>> ozwpf mailing list
>>> [email protected]
>>> http://prdlxvm0001.codify.net/mailman/listinfo/ozwpf****
>>>
>>> _______________________________________________
>>> ozwpf mailing list
>>> [email protected]
>>> http://prdlxvm0001.codify.net/mailman/listinfo/ozwpf
>>>
>>>
>> _______________________________________________
>> ozwpf mailing list
>> [email protected]
>> http://prdlxvm0001.codify.net/mailman/listinfo/ozwpf
>>
>>
>
> _______________________________________________
> ozwpf mailing list
> [email protected]
> http://prdlxvm0001.codify.net/mailman/listinfo/ozwpf
>
>
_______________________________________________
ozwpf mailing list
[email protected]
http://prdlxvm0001.codify.net/mailman/listinfo/ozwpf

Reply via email to