Hi Adrian,

I haven't tried, but something like this might work:

private Foo _foo;

public Foo Foo
{
    get { return _foo; }
    set { _foo = value; NotifyChanged("Foo"); }
}

public FooViewModel(Foo foo, Baz baz)
{
     Foo = foo;
     Property(() => Foo.Bar);

     baz.SomeEvent += () => Foo = new Foo();
}

By doing this, the MicroModels expression walker should also subscribe to the 
Foo property change event and re-evaluate when it changes.

Paul



From: [email protected] [mailto:[email protected]] On 
Behalf Of Adrian Hara
Sent: Monday, 15 March 2010 7:16 PM
To: [email protected]
Subject: MicroModels question

Hi,

I'm playing with the very-cool MicroModels framework from Paul Stovell, but I 
have a question. Suppose I have this view model

Class FooViewModel : MicroModel
{
    Public FooViewModel(Foo foo, Baz baz)
    {
         Property(() => foo.Bar);

         baz.SomeEvent += () => foo = new Foo();
    }
}

So the idea is that the underlying domain object upon which the view model is 
based (in this case the instance of Foo) can change (e.g. in response to some 
event). In this case the micro-model properties are "lost", i.e. they are still 
"subscribed" to the old instance of Foo and not to the new one.

What would be a good solution in this case so the properties get re-wired to 
use the new instance of Foo?

Thanks,
Adrian
_______________________________________________
ozwpf mailing list
[email protected]
http://prdlxvm0001.codify.net/mailman/listinfo/ozwpf

Reply via email to