Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Thought: MVVM eliminates 99% of the need for ValueConverters
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 26 - 50 of 70 - Collapse all  -  Translate all to Translated (View all originals) < Older  Newer >
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Mike Brown  
View profile  
 More options Dec 1 2008, 4:03 pm
From: "Mike Brown" <mbrow...@gmail.com>
Date: Mon, 1 Dec 2008 16:03:30 -0500
Local: Mon, Dec 1 2008 4:03 pm
Subject: Re: [WPF Disciples] Re: Thought: MVVM eliminates 99% of the need for ValueConverters

I always said that I like my views to be like a stereotypical cheerleader:
dumb and pretty. Note I said "stereotypical" I know that not all
cheerleaders are dumb or even pretty for that matter. The same can be said
for UI.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mike Brown  
View profile  
 More options Dec 1 2008, 3:59 pm
From: "Mike Brown" <mbrow...@gmail.com>
Date: Mon, 1 Dec 2008 15:59:00 -0500
Subject: Re: [WPF Disciples] Re: Thought: MVVM eliminates 99% of the need for ValueConverters

I think that in the series that Dan Crevier wrote, he definitely viewed the
ViewModel as a "Model of the View". The domain model itself is where the
logic of your application belongs. The ViewModel to me should indeed be just
that.

On Mon, Dec 1, 2008 at 3:31 PM, Laurent Bugnion, GalaSoft [MVP]


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Josh Smith  
View profile  
 More options Dec 1 2008, 4:07 pm
From: "Josh Smith" <flappleja...@gmail.com>
Date: Mon, 1 Dec 2008 16:07:08 -0500
Local: Mon, Dec 1 2008 4:07 pm
Subject: Re: [WPF Disciples] Re: Thought: MVVM eliminates 99% of the need for ValueConverters

I agree with you on that, Mike.  Code-behind is where you handle events of
controls in the View, and maybe update/call the VM in certain situations.
VM is where you store view state, handle user interactions, and indirectly
manipulate the UI elements.  Model is for domain "stuff."  That's my way of
seeing it, these days.

Josh


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bill Kempf  
View profile  
 More options Dec 1 2008, 4:09 pm
From: "Bill Kempf" <weke...@gmail.com>
Date: Mon, 1 Dec 2008 16:09:20 -0500
Local: Mon, Dec 1 2008 4:09 pm
Subject: Re: [WPF Disciples] Re: Thought: MVVM eliminates 99% of the need for ValueConverters
Again, though, just because your view is dumb doesn't mean your view
model should be doing "presentation work" that tightly couples it.

--
 Quidquid latine dictum sit, altum sonatur.
- Whatever is said in Latin sounds profound.

War is peace. Freedom is slavery.  Bugs are features.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Josh Smith  
View profile  
 More options Dec 1 2008, 4:11 pm
From: "Josh Smith" <flappleja...@gmail.com>
Date: Mon, 1 Dec 2008 16:11:44 -0500
Local: Mon, Dec 1 2008 4:11 pm
Subject: Re: [WPF Disciples] Re: Thought: MVVM eliminates 99% of the need for ValueConverters

If there is a one-to-one relationship between a ViewModel and a View, I
don't see why tight-coupling is a concern.  If we're talking about
"ModelViews" instead, as per my previous post, then I can see how the
coupling issue becomes more important.  Do you agree?

Josh


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bill Kempf  
View profile  
 More options Dec 1 2008, 4:14 pm
From: "Bill Kempf" <weke...@gmail.com>
Date: Mon, 1 Dec 2008 16:14:35 -0500
Local: Mon, Dec 1 2008 4:14 pm
Subject: Re: [WPF Disciples] Re: Thought: MVVM eliminates 99% of the need for ValueConverters
Not really.  Even if I'm only ever going to have one view, that view
is likely to still be fluid in nature.  What I mean by that is the
design of the view will go through many iterations throughout the
lifetime of the application, and tight coupling means changes to the
view also require changes to the view model.

--
 Quidquid latine dictum sit, altum sonatur.
- Whatever is said in Latin sounds profound.

War is peace. Freedom is slavery.  Bugs are features.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
corradocava...@gmail.com  
View profile  
 More options Dec 1 2008, 4:32 pm
From: corradocava...@gmail.com
Date: Mon, 1 Dec 2008 13:32:49 -0800 (PST)
Local: Mon, Dec 1 2008 4:32 pm
Subject: Re: Thought: MVVM eliminates 99% of the need for ValueConverters
Josh,
From my point of view, converters become part of a common library i
can share among projects, at least most commons (e.g:
BooleanToVisibility for SL projects), of course I won't ask a designer
to write code, but normally i create a very dumb preview, then
designer kicks in and does the rest, this when designer is involved,
and believe me, not many customer have designers.
Let's say you have a IsAvailable property on VM that you want to use
both Visibility trigger and Enabled property, your approach is to add
an additional property of type Visibility and this "doubling" must be
done for every VM while i can avoid this using a converter.
About testing: why do i have to test "Visibility" issues? my VM should
tell me that an item IsAvailable then its the view responsability to
convert that info in visibility (today, tomorrow it might change, and
i don't want to modify my VM for the new UI needs)

-Corrado

On Dec 1, 9:02 pm, "Josh Smith" <flappleja...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Josh Smith  
View profile  
 More options Dec 1 2008, 4:40 pm
From: "Josh Smith" <flappleja...@gmail.com>
Date: Mon, 1 Dec 2008 16:40:37 -0500
Local: Mon, Dec 1 2008 4:40 pm
Subject: Re: [WPF Disciples] Re: Thought: MVVM eliminates 99% of the need for ValueConverters

Thanks Corrado.  I get where you're coming from with this, but I'm still
unsure of where the "boundary" is.  One could take this reasoning and push
it to the extreme by stating "Why bother with a ViewModel at all?  Why not
just bind directly to the Model and use Value Converters to handle all other
transformations that need to be applied to make the Model show up in the UI
correctly?"

Clearly, I know that nobody here is promoting that idea.  The balance of
power, so to speak, between ViewModel and View is a spectrum in which I lean
toward the left and many others seem to lean more toward the right.  I'm
wondering what guiding principles one should use to find the sweet spot
between the two opposing forces.

Josh


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jeremiah Morrill  
View profile  
 More options Dec 1 2008, 5:02 pm
From: "Jeremiah Morrill" <jeremiah.morr...@gmail.com>
Date: Mon, 1 Dec 2008 14:02:23 -0800
Local: Mon, Dec 1 2008 5:02 pm
Subject: Re: [WPF Disciples] Re: Thought: MVVM eliminates 99% of the need for ValueConverters

Josh,

Crack.NET has been one of my bases of learning MVVM.  I think the typed
datatemplate resources feel very natural and lets the View be as only
intelligent as it needs to be.  As you remember, this is where I was sorta
getting pattern gun-shy in SL, given lack of built in support.  At this
moment, I'm a proponent of the ViewModel-data/type-driven View which you
mentioned here.  Before, in SL, I was initializing the VM in the codebehind
and clearly it was more spaghettified if my goal was to *fly the whole plane
*from the VM.

As far as ValueConverters go, I would say I'm guilty of having my VM pander
the View a little bit.  I would also add that I don't enjoy making VCs that
much...but just like home-owners-associations, they are a necessary evil.
Most cases I would assume it's fine to have View friendly properties...but
when you start getting over run by redundant properties (in other formats)
is when I may consider a VC.

Just my 2cents as a newbie ;).  It does feel good to be able to follow these
conversations now though...

-Jer


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Corrado Cavalli  
View profile  
 More options Dec 1 2008, 5:08 pm
From: "Corrado Cavalli" <corradocava...@gmail.com>
Date: Mon, 1 Dec 2008 23:08:34 +0100
Local: Mon, Dec 1 2008 5:08 pm
Subject: RE: [WPF Disciples] Re: Thought: MVVM eliminates 99% of the need for ValueConverters

I love this kind of discussions they helps spreading opinions and helps me
(and hope others) play better  with this “quite young” but promising
pattern.

I’m not absolutely saying your solution is bad, e.g. I use it when I need to
enable an element as result of a complex condition
(DataTrigger/Multibinding? No thanks! J) and, my point of view is that
patterns are ‘indications’ and I feel free to adapt them in the way the best
fits my solution.

Unfortunately I keep seeing architects that apply patterns “as-is” even if
that results in more complex code.

-Corrado

From: wpf-disciples@googlegroups.com [mailto:wpf-disciples@googlegroups.com]
On Behalf Of Josh Smith
Sent: lunedì 1 dicembre 2008 22:41
To: wpf-disciples@googlegroups.com
Subject: [WPF Disciples] Re: Thought: MVVM eliminates 99% of the need for
ValueConverters

Thanks Corrado.  I get where you're coming from with this, but I'm still
unsure of where the "boundary" is.  One could take this reasoning and push
it to the extreme by stating "Why bother with a ViewModel at all?  Why not
just bind directly to the Model and use Value Converters to handle all other
transformations that need to be applied to make the Model show up in the UI
correctly?"  

Clearly, I know that nobody here is promoting that idea.  The balance of
power, so to speak, between ViewModel and View is a spectrum in which I lean
toward the left and many others seem to lean more toward the right.  I'm
wondering what guiding principles one should use to find the sweet spot
between the two opposing forces.

Josh

On Mon, Dec 1, 2008 at 4:32 PM, <corradocava...@gmail.com> wrote:

Josh,
From my point of view, converters become part of a common library i
can share among projects, at least most commons (e.g:
BooleanToVisibility for SL projects), of course I won't ask a designer
to write code, but normally i create a very dumb preview, then
designer kicks in and does the rest, this when designer is involved,
and believe me, not many customer have designers.
Let's say you have a IsAvailable property on VM that you want to use
both Visibility trigger and Enabled property, your approach is to add
an additional property of type Visibility and this "doubling" must be
done for every VM while i can avoid this using a converter.
About testing: why do i have to test "Visibility" issues? my VM should
tell me that an item IsAvailable then its the view responsability to
convert that info in visibility (today, tomorrow it might change, and
i don't want to modify my VM for the new UI needs)

-Corrado

On Dec 1, 9:02 pm, "Josh Smith" <flappleja...@gmail.com> wrote:

> Suppose you're working in the designer-developer workflow.  Should the
> designers have to write the value converters?  What if they don't know how
> to write some of them?  I think it's easier to have the VM expose the
> properties that they need to bind against, instead of having the designers
> ask the developers to write a bunch of one-off converters for them.

> At the end of the day, MVVM (like any other pattern) is a set of
guidelines,
> not rules.  So, as long as using the pattern makes your application
better,
> development easier, and testing more thorough, it's all good.

> Josh

> On Mon, Dec 1, 2008 at 2:54 PM, Corrado Cavalli

<corradocava...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Josh Smith  
View profile  
 More options Dec 1 2008, 5:11 pm
From: "Josh Smith" <flappleja...@gmail.com>
Date: Mon, 1 Dec 2008 17:11:36 -0500
Local: Mon, Dec 1 2008 5:11 pm
Subject: Re: [WPF Disciples] Re: Thought: MVVM eliminates 99% of the need for ValueConverters

Me too, Corrado.  Having discussions like this really help open new horizons
for me.

>> Unfortunately I keep seeing architects that apply patterns "as-is" even

if that results in more complex code.

I'd take complex code over complex XAML any day!  As you pointed out,
hanging a property off the VM which returns a complex calculated value is
definitely easier to maintain than a fat chunk of XAML using MultiBindings
and a MultiConverter.

Josh

On Mon, Dec 1, 2008 at 5:08 PM, Corrado Cavalli <corradocava...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Josh Smith  
View profile  
 More options Dec 1 2008, 5:13 pm
From: "Josh Smith" <flappleja...@gmail.com>
Date: Mon, 1 Dec 2008 17:13:09 -0500
Local: Mon, Dec 1 2008 5:13 pm
Subject: Re: [WPF Disciples] Re: Thought: MVVM eliminates 99% of the need for ValueConverters

Jer,

I'm glad Crack has had the fringe benefit of being educational!  That's
great news for me!! :)

Josh

On Mon, Dec 1, 2008 at 5:02 PM, Jeremiah Morrill <jeremiah.morr...@gmail.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jeremiah Morrill  
View profile  
 More options Dec 1 2008, 5:15 pm
From: "Jeremiah Morrill" <jeremiah.morr...@gmail.com>
Date: Mon, 1 Dec 2008 14:15:55 -0800
Local: Mon, Dec 1 2008 5:15 pm
Subject: Re: [WPF Disciples] Re: Thought: MVVM eliminates 99% of the need for ValueConverters

Don't want to inflate your ego dude, but if code was porn, the Crack.NET
source would be illegal in all 50 states!  Too hot!

Many thanks though.

-Jer


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Laurent Bugnion, GalaSoft [MVP]  
View profile  
 More options Dec 1 2008, 5:21 pm
From: "Laurent Bugnion, GalaSoft [MVP]" <laur...@galasoft.ch>
Date: Mon, 1 Dec 2008 23:21:57 +0100
Local: Mon, Dec 1 2008 5:21 pm
Subject: RE: [WPF Disciples] Re: Thought: MVVM eliminates 99% of the need for ValueConverters

You know, thinking about what I wrote earlier, I think that the “sweet
balance” really depends on a lot of factors.

- Does your project have designers or not?

- How experienced is your team?

- How much unit testing do you do (don’t laugh, I love unit tests but many
managers hate it and don’t see the value of it, true story)

- What is your model made of and where does it come from?

- and of course personal preferences.

From: wpf-disciples@googlegroups.com [mailto:wpf-disciples@googlegroups.com]
On Behalf Of Josh Smith
Sent: Monday, December 01, 2008 10:41 PM
To: wpf-disciples@googlegroups.com
Subject: [WPF Disciples] Re: Thought: MVVM eliminates 99% of the need for
ValueConverters

Thanks Corrado.  I get where you're coming from with this, but I'm still
unsure of where the "boundary" is.  One could take this reasoning and push
it to the extreme by stating "Why bother with a ViewModel at all?  Why not
just bind directly to the Model and use Value Converters to handle all other
transformations that need to be applied to make the Model show up in the UI
correctly?"  

Clearly, I know that nobody here is promoting that idea.  The balance of
power, so to speak, between ViewModel and View is a spectrum in which I lean
toward the left and many others seem to lean more toward the right.  I'm
wondering what guiding principles one should use to find the sweet spot
between the two opposing forces.

Josh

On Mon, Dec 1, 2008 at 4:32 PM, <corradocava...@gmail.com> wrote:

Josh,
From my point of view, converters become part of a common library i
can share among projects, at least most commons (e.g:
BooleanToVisibility for SL projects), of course I won't ask a designer
to write code, but normally i create a very dumb preview, then
designer kicks in and does the rest, this when designer is involved,
and believe me, not many customer have designers.
Let's say you have a IsAvailable property on VM that you want to use
both Visibility trigger and Enabled property, your approach is to add
an additional property of type Visibility and this "doubling" must be
done for every VM while i can avoid this using a converter.
About testing: why do i have to test "Visibility" issues? my VM should
tell me that an item IsAvailable then its the view responsability to
convert that info in visibility (today, tomorrow it might change, and
i don't want to modify my VM for the new UI needs)

-Corrado

On Dec 1, 9:02 pm, "Josh Smith" <flappleja...@gmail.com> wrote:

> Suppose you're working in the designer-developer workflow.  Should the
> designers have to write the value converters?  What if they don't know how
> to write some of them?  I think it's easier to have the VM expose the
> properties that they need to bind against, instead of having the designers
> ask the developers to write a bunch of one-off converters for them.

> At the end of the day, MVVM (like any other pattern) is a set of
guidelines,
> not rules.  So, as long as using the pattern makes your application
better,
> development easier, and testing more thorough, it's all good.

> Josh

> On Mon, Dec 1, 2008 at 2:54 PM, Corrado Cavalli

<corradocava...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jeremiah Morrill  
View profile  
 More options Dec 1 2008, 5:13 pm
From: "Jeremiah Morrill" <jeremiah.morr...@gmail.com>
Date: Mon, 1 Dec 2008 14:13:05 -0800
Local: Mon, Dec 1 2008 5:13 pm
Subject: Re: [WPF Disciples] Re: Thought: MVVM eliminates 99% of the need for ValueConverters

One question, about creating a life cycle for a VM, is what mechanism would
you use in SL to do this?  I was hoping not to have to do anything with the
VM in the code-behind as this would create too much coupling (for my
liking).

On Mon, Dec 1, 2008 at 2:02 PM, Jeremiah Morrill <jeremiah.morr...@gmail.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Josh Smith  
View profile  
 More options Dec 1 2008, 5:28 pm
From: "Josh Smith" <flappleja...@gmail.com>
Date: Mon, 1 Dec 2008 17:28:55 -0500
Local: Mon, Dec 1 2008 5:28 pm
Subject: Re: [WPF Disciples] Re: Thought: MVVM eliminates 99% of the need for ValueConverters

Thanks Jer.  Glad you like it.  :)

On Mon, Dec 1, 2008 at 5:15 PM, Jeremiah Morrill <jeremiah.morr...@gmail.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Josh Smith  
View profile  
 More options Dec 1 2008, 5:30 pm
From: "Josh Smith" <flappleja...@gmail.com>
Date: Mon, 1 Dec 2008 17:30:07 -0500
Local: Mon, Dec 1 2008 5:30 pm
Subject: Re: [WPF Disciples] Re: Thought: MVVM eliminates 99% of the need for ValueConverters

You're totally right, Laurent.  It's a moving target.  Regarding the
"managers who don't like unit testing" thing...been there, done that. :-\

Josh

On Mon, Dec 1, 2008 at 5:21 PM, Laurent Bugnion, GalaSoft [MVP]


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Josh Smith  
View profile  
 More options Dec 1 2008, 5:36 pm
From: "Josh Smith" <flappleja...@gmail.com>
Date: Mon, 1 Dec 2008 17:36:19 -0500
Local: Mon, Dec 1 2008 5:36 pm
Subject: Re: [WPF Disciples] Re: Thought: MVVM eliminates 99% of the need for ValueConverters

Jer,

In Crack.NET there is only the "Initialize" phase of the lifecycle.  This
occurs in InjectedWindowViewModel, as seen below...

TWorkspace FindOrCreateWorkspace<TWorkspace>() where TWorkspace :
WorkspaceViewModel, new()
{
    TWorkspace workspace = this.Workspaces.FirstOrDefault(ws => ws is
TWorkspace) as TWorkspace;

    if (workspace == null || workspace.AllowMultipleInstances)
    {
        workspace = new TWorkspace();
*        workspace.Initialize(this);*
        workspace.RequestClose += this.OnWorkspaceRequestClose;
    }

    return workspace;

}

ScriptoriumViewModel overrides Initialize to perform some setup code.  The
base impl only sets the _owner field.

If I ever need to have a "Dispose" phase for ViewModel objects, I'd put it
into InjectedWindowViewModel like so...

void OnWorkspaceRequestClose(object sender, EventArgs e)
{
    WorkspaceViewModel workspace = sender as WorkspaceViewModel;
    workspace.RequestClose -= this.OnWorkspaceRequestClose;
    _workspacesInternal.Remove(workspace);

*    // This method call does not exist...
    workspace.Dispose();*

}

Josh

On Mon, Dec 1, 2008 at 5:13 PM, Jeremiah Morrill <jeremiah.morr...@gmail.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jeremiah Morrill  
View profile  
 More options Dec 1 2008, 5:48 pm
From: "Jeremiah Morrill" <jeremiah.morr...@gmail.com>
Date: Mon, 1 Dec 2008 14:48:46 -0800
Local: Mon, Dec 1 2008 5:48 pm
Subject: Re: [WPF Disciples] Re: Thought: MVVM eliminates 99% of the need for ValueConverters

Ah ha!  I was under the impression that you guys were talking about running
an initialize on the View's loaded event...which I haven't had a need for
thus far.  I know as this project gets bigger, I may need, or decided I need
some sort of life-cycle in the VM..so I'm trying to sneak in as many
questions now as possible :)

-Jer


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Josh Smith  
View profile  
 More options Dec 1 2008, 5:51 pm
From: "Josh Smith" <flappleja...@gmail.com>
Date: Mon, 1 Dec 2008 17:51:52 -0500
Local: Mon, Dec 1 2008 5:51 pm
Subject: Re: [WPF Disciples] Re: Thought: MVVM eliminates 99% of the need for ValueConverters

I wasn't referring specifically to the implementation details of how a
lifecycle is managed.  If people are loading VMs from the View, then it
makes sense to manage the lifecycle from the View.  In my apps, I load the
View in response to putting a VM into the UI, so I manage the lifecycle from
the place in my app that creates/loads/removes VM objects.

josh

On Mon, Dec 1, 2008 at 5:48 PM, Jeremiah Morrill <jeremiah.morr...@gmail.com

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Laurent Bugnion, GalaSoft [MVP]  
View profile  
 More options Dec 1 2008, 5:52 pm
From: "Laurent Bugnion, GalaSoft [MVP]" <laur...@galasoft.ch>
Date: Mon, 1 Dec 2008 23:52:53 +0100
Local: Mon, Dec 1 2008 5:52 pm
Subject: RE: [WPF Disciples] Re: Thought: MVVM eliminates 99% of the need for ValueConverters

Jer, using the Silverlight toolkit you can now define implicit styles so I
*suppose* (but I didn’t try it) that you could also use the
ImplicitStyleManager to define a View for a given view model type…
interesting thought, I have to try that… tomorrow. ;)

http://blog.galasoft.ch/archive/2008/10/28/new-silverlight-controls-s...
livered-by-microsoft-pdc08.aspx

Laurent

From: wpf-disciples@googlegroups.com [mailto:wpf-disciples@googlegroups.com]
On Behalf Of Jeremiah Morrill
Sent: Monday, December 01, 2008 11:02 PM
To: wpf-disciples@googlegroups.com
Subject: [WPF Disciples] Re: Thought: MVVM eliminates 99% of the need for
ValueConverters

Josh,

Crack.NET has been one of my bases of learning MVVM.  I think the typed
datatemplate resources feel very natural and lets the View be as only
intelligent as it needs to be.  As you remember, this is where I was sorta
getting pattern gun-shy in SL, given lack of built in support.  At this
moment, I'm a proponent of the ViewModel-data/type-driven View which you
mentioned here.  Before, in SL, I was initializing the VM in the codebehind
and clearly it was more spaghettified if my goal was to fly the whole plane
from the VM.  

As far as ValueConverters go, I would say I'm guilty of having my VM pander
the View a little bit.  I would also add that I don't enjoy making VCs that
much...but just like home-owners-associations, they are a necessary evil.
Most cases I would assume it's fine to have View friendly properties...but
when you start getting over run by redundant properties (in other formats)
is when I may consider a VC.

Just my 2cents as a newbie ;).  It does feel good to be able to follow these
conversations now though...

-Jer

On Mon, Dec 1, 2008 at 12:55 PM, Josh Smith <flappleja...@gmail.com> wrote:

Great feedback, Laurent.  Looking forward to your upcoming blog post about
your experience with taking other approaches. ;)

I sense that I'm the odd man out in this discussion.  I'm very curious to
know what concrete advantages others have gained by treating the VM as
something clearly distinct and separate from the View.  What do you really
gain from using value converters and code-behind logic, as opposed to
putting that stuff into the VM?  I'm not opposed to that approach, it's just
not how I've done MVVM so far.  While working on Crack.NET I created very
dumb, passive Views and smart, demanding ViewModels.  I know that the good
Doctor is quite versed in MVVM, and has reviewed the Crack code, so I'd love
to hear his thoughts on this.

josh

On Mon, Dec 1, 2008 at 3:31 PM, Laurent Bugnion, GalaSoft [MVP]

<laur...@galasoft.ch> wrote:

I want to chime in on that one.

Yes, patterns are guidelines more than rules. I followed that discussion
with very much interest and can't wait to try some of that in my next app,
and it's really interesting to see the different streams of thoughts. So far
I think I see two major variations in the exposed practices, one which
considers that VM is a kind of replacement for code-behind (let's call it a
top-down approach) and thus a VM is very tightly bound to a View. The other
is rather a bottom-up approach and puts the VM as an extension of the model,
but formatted for the View.

In the project I worked last, we took a very pragmatic approach, and used VM
for various reasons, the most important being avoiding that our designers
have to write any code. Josh's point is really valid, designers should not
have to worry about code, period. It's not their job. My role as an
integrator (IM calls that "Interactive Developer") was to specifically avoid
designers to have that kind of problems. This results in a series of
roundtrips between developers and designers coordinated by the integrator.
In that sense, a well thought VM can avoid a number of roundtrips. To me,
this is the most important aspect of the VM, because every roundtrip costs a
lot of money, and designers are damn expensive in a project.

When I say we were pragmatic, I mean that because some in the team were
quite unexperienced, we ended up having quite some code in the code-behind.
If I had to do it again today, I would probably be stricter about that. But
on the other hand, I saw another team take a much stricter approach (Josh:
That was Linus' team, you probably remember him from our memorable dinner in
NY) and they spent a lot more time on some details than we did. Also, some
of the development was done in India, and their strict approach cost quite a
lot of time round tripping between India and Switzerland, or worse, having
to refactor much of the code that the Indian team delivered.

Anyway… my next project should be a much smaller one (Silverlight), and I
want to apply MVVM in a stricter way there. That should be interesting J

From: wpf-disciples@googlegroups.com [mailto:wpf-disciples@googlegroups.com]
On Behalf Of Josh Smith
Sent: Monday, December 01, 2008 9:03 PM

To: wpf-disciples@googlegroups.com
Subject: [WPF Disciples] Re: Thought: MVVM eliminates 99% of the need for
ValueConverters

Suppose you're working in the designer-developer workflow.  Should the
designers have to write the value converters?  What if they don't know how
to write some of them?  I think it's easier to have the VM expose the
properties that they need to bind against, instead of having the designers
ask the developers to write a bunch of one-off converters for them.

At the end of the day, MVVM (like any other pattern) is a set of guidelines,
not rules.  So, as long as using the pattern makes your application better,
development easier, and testing more thorough, it's all good.

Josh

On Mon, Dec 1, 2008 at 2:54 PM, Corrado Cavalli <corradocava...@gmail.com>
wrote:

I'm with Marlon on this, while I agree that the VM can eliminate all
converters  I don't like the idea of having a ViewModel too tied to the view
and, after all, converters are very reusable J.

Just had a look at Silverlight validation model, think there's a lot of work
to do to fit it in a M-V-VM environment…

-Corrado

From: wpf-disciples@googlegroups.com [mailto:wpf-disciples@googlegroups.com]
On Behalf Of Marlon Grech
Sent: lunedì 1 dicembre 2008 20:16

To: wpf-disciples@googlegroups.com
Subject: [WPF Disciples] Re: Thought: MVVM eliminates 99% of the need for
ValueConverters

I also think that this should be 50% 50%... If there is something strongly
UI coupled then I would probably put it in a ValueConverter...

yet I must say I hate those creatures so called IValueConverters :/

Regards
Marlon
WPF Blog - http://marlongrech.wordpress.com/

On Mon, Dec 1, 2008 at 5:08 PM, Josh Smith <flappleja...@gmail.com> wrote:

A ViewModel is basically a value converter on steroids.  I takes "raw" data
and converts it into something presentation-friendly, and vice-versa.  If
you ever find yourself binding an element's property to a ViewModel's
property, and you're using a value converter, stop!  Why not just create a
property on the ViewModel that exposes the "formatted" data, and then drop
the value converter altogether?

The only place I can see a use for value converters in an MVVM architecture
is cross-element bindings.  If I'm binding the Visibility of a panel to the
IsChecked of a CheckBox, then I will need to use the
BooleanToVisibilityConverter.  But, perhaps even in that case I should take
the "high road" and bind the IsChecked to a property on the ViewModel, and
then have a SomePanelVisibility property on the VM, to which the Panel is
bound.

Do you agree???


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jeremiah Morrill  
View profile  
 More options Dec 1 2008, 6:04 pm
From: "Jeremiah Morrill" <jeremiah.morr...@gmail.com>
Date: Mon, 1 Dec 2008 15:04:13 -0800
Local: Mon, Dec 1 2008 6:04 pm
Subject: Re: [WPF Disciples] Re: Thought: MVVM eliminates 99% of the need for ValueConverters

I'll have to check it out...Actually, I'm going to check it out right after
this email!

I've been using the ResourceSelector from the SL
Extensions<http://slextensions.net/showcase.aspx#Page=20>,
which is a simple, but very powerful class.  Totally makes up for the fact
there are no typed datatemplates.

So essentially, I have a VM with a property called CurrentViewModel, of my
ViewModelBase type.  I just have content control bind it's content to this
property, and bind the ContentTemplate to a DataTemplate that uses the
ResourceSelector.  This way, whatever .NET type my VM is, the View will pick
the right datatemplate...just like WPF.  Here is the XAML for it.  The
"x:Key="LoginViewModel", LoginViewModel is the name of my ViewModel type.
It also supports the type FullName if you really need.

    <UserControl.Resources>
        <Data:ResourceSelector x:Key="controlTemplateSelector">
            <ResourceDictionary>
                <DataTemplate x:Key="LoginViewModel">
                    <Views:LoginView Height="{TemplateBinding Height}" />
                </DataTemplate>
                <DataTemplate x:Key="EventQueryViewModel">
                    <Views:EventQueryView />
                </DataTemplate>
            </ResourceDictionary>
        </Data:ResourceSelector>
        <DataTemplate x:Key="controlItemTemplate">
            <ContentControl Content="{Binding}"
                            ContentTemplate="{Binding
Converter={StaticResource controlTemplateSelector}}" />
        </DataTemplate>
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot">
        <Image Source="Assets/mainBackground.jpg"
               Stretch="Fill"
               Opacity="0.5" />
        <Controls:SwappableContentControl Content="{Binding
CurrentViewModel}"
                                          Background="Transparent"
                                          ContentTemplate="{StaticResource
controlItemTemplate}"
                                          VerticalAlignment="Center" />

    </Grid>
</UserControl>

On Mon, Dec 1, 2008 at 2:52 PM, Laurent Bugnion, GalaSoft [MVP]

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jeremiah Morrill  
View profile  
 More options Dec 1 2008, 6:28 pm
From: "Jeremiah Morrill" <jeremiah.morr...@gmail.com>
Date: Mon, 1 Dec 2008 15:28:26 -0800
Local: Mon, Dec 1 2008 6:28 pm
Subject: Re: [WPF Disciples] Re: Thought: MVVM eliminates 99% of the need for ValueConverters

This ImplicitStyleManager is rad Laurent!  It doesn't solve the issue of no
typed datatemplates, but it sure fixes other issues..Like no support for
merged resource dictionaries...of of course, implicit styles =P

-Jer

On Mon, Dec 1, 2008 at 3:04 PM, Jeremiah Morrill <jeremiah.morr...@gmail.com

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mike Brown  
View profile  
 More options Dec 1 2008, 6:35 pm
From: "Mike Brown" <mbrow...@gmail.com>
Date: Mon, 1 Dec 2008 18:35:14 -0500
Local: Mon, Dec 1 2008 6:35 pm
Subject: Re: [WPF Disciples] Re: Thought: MVVM eliminates 99% of the need for ValueConverters

Prism does a good job at handling all that wiring cruft that you don't want
to deal with and I hear that the new version targets SL so that the same VM
CAN be used for an SL app as well as a full WPF app. BTW, now that SL will
have 3D and hardware acceleration capabilities, is there anything preventing
it from being the preferred desktop client framework?

On Mon, Dec 1, 2008 at 6:28 PM, Jeremiah Morrill <jeremiah.morr...@gmail.com

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jeremiah Morrill  
View profile  
 More options Dec 1 2008, 6:40 pm
From: "Jeremiah Morrill" <jeremiah.morr...@gmail.com>
Date: Mon, 1 Dec 2008 15:40:42 -0800
Local: Mon, Dec 1 2008 6:40 pm
Subject: Re: [WPF Disciples] Re: Thought: MVVM eliminates 99% of the need for ValueConverters

>>is there anything preventing it from being the preferred desktop client

framework

Hard to say until we see what the caveats are to 3D and HW acceleration.
Flash 10 has those, but it's still neutered and sandboxed.

The apps I usually work on (if they were WPF), are pretty market
specific...So I *need* full trust, COM interop, p/invoke, etc.  Most biz
apps don't need this, but I don't think SL will take down WPF anytime with
me ;)

-Jer

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Messages 26 - 50 of 70 < Older  Newer >
« Back to Discussions « Newer topic     Older topic »