Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Silverlight + MVVM = More questions
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
  20 messages - Collapse all  -  Translate all to Translated (View all originals)
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
 
Jeremiah Morrill  
View profile  
 More options Nov 28 2008, 11:39 pm
From: "Jeremiah Morrill" <jeremiah.morr...@gmail.com>
Date: Fri, 28 Nov 2008 20:39:08 -0800
Local: Fri, Nov 28 2008 11:39 pm
Subject: Silverlight + MVVM = More questions

I'm still trying to grok, as they say, MVVM in Silverlight.  So if any of
this sounds ignorant, don't be shy about letting me know.

So essentially I have a ViewModel such as this:

    public class MainLayoutViewModel : ViewModelBase
    {
        private LoginViewModel m_loginController = new LoginViewModel();
        private TestViewModel m_testController = new TestViewModel();
        private ViewModelBase m_currentViewModel;

        public MainLayoutViewModel()
        {
            CurrentViewModel = m_loginController;
        }

        public ViewModelBase CurrentViewModel
        {
            get { return m_currentViewModel; }
            set
            {
                m_currentViewModel = value;
                InvokePropertyChanged("CurrentViewModel");
            }
        }
    }

Now when my LoginViewModell "authenticates", I suppose I want to change the
"CurrentViewModel" property to a new view model.  In my View, I would like
to change the DataTemplate "View" to the matching ViewModel, but it seems
something like this is not supported in SL.  I found some great support for
this in the SL Extensions <http://slextensions.net> (ResourceSelector), *but
I was wondering how everyone else does this, or if there is a better way* or
if I'm just doin' it wrong?  My View with the SL extension looks like this:

<UserControl x:Class="SKMEventUI.MainLayoutView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Views="clr-namespace:MyNamespace.Views"
    xmlns:Data="clr-namespace:SLExtensions.Data;assembly=SLExtensions"

xmlns:Controls="clr-namespace:SLExtensions.Controls;assembly=SLExtensions.C ontrols">
    <UserControl.Resources>
        <Data:ResourceSelector x:Key="controlTemplateSelector">
            <ResourceDictionary>
                <DataTemplate x:Key="LoginViewModel">
                    <Border BorderBrush="Black" BorderThickness="1,1,1,1">
                        <Views:LoginView/>
                    </Border>
                </DataTemplate>
                <DataTemplate x:Key="TestViewModel">
                    <Views:TestView />
                </DataTemplate>
            </ResourceDictionary>
        </Data:ResourceSelector>
        <DataTemplate x:Key="controlItemTemplate">
            <ContentControl Content="{Binding}"
                            ContentTemplate="{Binding
Converter={StaticResource controlTemplateSelector}}" />
        </DataTemplate>
    </UserControl.Resources>
    <StackPanel x:Name="LayoutRoot" Background="White">
                <ContentControl  Content="{Binding CurrentViewModel}"
                         ContentTemplate="{StaticResource
controlItemTemplate}" />
    </StackPanel>
</UserControl>


    Reply to author    Forward  
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 Nov 29 2008, 12:25 am
From: "Corrado Cavalli" <corradocava...@gmail.com>
Date: Sat, 29 Nov 2008 06:25:55 +0100
Local: Sat, Nov 29 2008 12:25 am
Subject: RE: [WPF Disciples] Silverlight + MVVM = More questions

Hi Jeremiah,

Are you trying to implement a sort of Login page then, after authentication,
do you want to 'move' to main page?

Corrado

From: wpf-disciples@googlegroups.com [mailto:wpf-disciples@googlegroups.com]
On Behalf Of Jeremiah Morrill
Sent: sabato 29 novembre 2008 05:39
To: wpf-disciples@googlegroups.com
Subject: [WPF Disciples] Silverlight + MVVM = More questions

I'm still trying to grok, as they say, MVVM in Silverlight.  So if any of
this sounds ignorant, don't be shy about letting me know.

So essentially I have a ViewModel such as this:

    public class MainLayoutViewModel : ViewModelBase
    {
        private LoginViewModel m_loginController = new LoginViewModel();
        private TestViewModel m_testController = new TestViewModel();
        private ViewModelBase m_currentViewModel;

        public MainLayoutViewModel()
        {
            CurrentViewModel = m_loginController;
        }

        public ViewModelBase CurrentViewModel
        {
            get { return m_currentViewModel; }
            set
            {
                m_currentViewModel = value;
                InvokePropertyChanged("CurrentViewModel");
            }
        }
    }

Now when my LoginViewModell "authenticates", I suppose I want to change the
"CurrentViewModel" property to a new view model.  In my View, I would like
to change the DataTemplate "View" to the matching ViewModel, but it seems
something like this is not supported in SL.  I found some great support for
this in the SL Extensions <http://slextensions.net>  (ResourceSelector), but
I was wondering how everyone else does this, or if there is a better way or
if I'm just doin' it wrong?  My View with the SL extension looks like this:

<UserControl x:Class="SKMEventUI.MainLayoutView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Views="clr-namespace:MyNamespace.Views"
    xmlns:Data="clr-namespace:SLExtensions.Data;assembly=SLExtensions"

xmlns:Controls="clr-namespace:SLExtensions.Controls;assembly=SLExtensions.C o
ntrols">
    <UserControl.Resources>
        <Data:ResourceSelector x:Key="controlTemplateSelector">
            <ResourceDictionary>
                <DataTemplate x:Key="LoginViewModel">
                    <Border BorderBrush="Black" BorderThickness="1,1,1,1">
                        <Views:LoginView/>
                    </Border>
                </DataTemplate>
                <DataTemplate x:Key="TestViewModel">
                    <Views:TestView />
                </DataTemplate>
            </ResourceDictionary>
        </Data:ResourceSelector>
        <DataTemplate x:Key="controlItemTemplate">
            <ContentControl Content="{Binding}"
                            ContentTemplate="{Binding
Converter={StaticResource controlTemplateSelector}}" />
        </DataTemplate>
    </UserControl.Resources>
    <StackPanel x:Name="LayoutRoot" Background="White">
                <ContentControl  Content="{Binding CurrentViewModel}"
                         ContentTemplate="{StaticResource
controlItemTemplate}" />
    </StackPanel>
</UserControl>


    Reply to author    Forward  
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 Nov 29 2008, 4:57 am
From: "Jeremiah Morrill" <jeremiah.morr...@gmail.com>
Date: Sat, 29 Nov 2008 01:57:29 -0800
Local: Sat, Nov 29 2008 4:57 am
Subject: Re: [WPF Disciples] Re: Silverlight + MVVM = More questions

Yeah, specifically here, that's exactly what I'm trying to accomplish.
Generally, I want be able to "replace one control with another", and of
course stick close to being MVVM.  The ContentControl would eventually be
replaced with something that would maybe do a transition when the content
changed.

I know some things need a little home-brew TLC in SL (ie Commanding), but I
am left wondering if I'm applying the pattern *incorrectly *and/or not
leveraging the SL framework.  So far, to me, making controls on a *lower *level
makes a lot of sense, but gluing them together at a higher level is where my
understanding of how to implement MVVM in SL falls apart.

-Jer

On Fri, Nov 28, 2008 at 9:25 PM, Corrado Cavalli
<corradocava...@gmail.com>wrote:


    Reply to author    Forward  
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 Nov 29 2008, 5:45 am
From: "Corrado Cavalli" <corradocava...@gmail.com>
Date: Sat, 29 Nov 2008 11:45:15 +0100
Local: Sat, Nov 29 2008 5:45 am
Subject: RE: [WPF Disciples] Re: Silverlight + MVVM = More questions

Think you're in wrong direction, you have to change rootvisual content, my
application uses a navigation system based on this blog and it works great!

In my case, I changed the logic a bit because, after login only the internal
area has to change based on navigation but approach is exactly the same

http://www.flawlesscode.com/post/2008/03/Silverlight-2-Navigating-Bet...
ml-Pages.aspx

Corrado

From: wpf-disciples@googlegroups.com [mailto:wpf-disciples@googlegroups.com]
On Behalf Of Jeremiah Morrill
Sent: sabato 29 novembre 2008 10:57
To: wpf-disciples@googlegroups.com
Subject: [WPF Disciples] Re: Silverlight + MVVM = More questions

Yeah, specifically here, that's exactly what I'm trying to accomplish.
Generally, I want be able to "replace one control with another", and of
course stick close to being MVVM.  The ContentControl would eventually be
replaced with something that would maybe do a transition when the content
changed.

I know some things need a little home-brew TLC in SL (ie Commanding), but I
am left wondering if I'm applying the pattern incorrectly and/or not
leveraging the SL framework.  So far, to me, making controls on a lower
level makes a lot of sense, but gluing them together at a higher level is
where my understanding of how to implement MVVM in SL falls apart.

-Jer

On Fri, Nov 28, 2008 at 9:25 PM, Corrado Cavalli <corradocava...@gmail.com>
wrote:

Hi Jeremiah,

Are you trying to implement a sort of Login page then, after authentication,
do you want to 'move' to main page?

Corrado

From: wpf-disciples@googlegroups.com [mailto:wpf-disciples@googlegroups.com]
On Behalf Of Jeremiah Morrill
Sent: sabato 29 novembre 2008 05:39
To: wpf-disciples@googlegroups.com
Subject: [WPF Disciples] Silverlight + MVVM = More questions

I'm still trying to grok, as they say, MVVM in Silverlight.  So if any of
this sounds ignorant, don't be shy about letting me know.

So essentially I have a ViewModel such as this:

    public class MainLayoutViewModel : ViewModelBase
    {
        private LoginViewModel m_loginController = new LoginViewModel();
        private TestViewModel m_testController = new TestViewModel();
        private ViewModelBase m_currentViewModel;

        public MainLayoutViewModel()
        {
            CurrentViewModel = m_loginController;
        }

        public ViewModelBase CurrentViewModel
        {
            get { return m_currentViewModel; }
            set
            {
                m_currentViewModel = value;
                InvokePropertyChanged("CurrentViewModel");
            }
        }
    }

Now when my LoginViewModell "authenticates", I suppose I want to change the
"CurrentViewModel" property to a new view model.  In my View, I would like
to change the DataTemplate "View" to the matching ViewModel, but it seems
something like this is not supported in SL.  I found some great support for
this in the SL Extensions <http://slextensions.net>  (ResourceSelector), but
I was wondering how everyone else does this, or if there is a better way or
if I'm just doin' it wrong?  My View with the SL extension looks like this:

<UserControl x:Class="SKMEventUI.MainLayoutView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Views="clr-namespace:MyNamespace.Views"
    xmlns:Data="clr-namespace:SLExtensions.Data;assembly=SLExtensions"

xmlns:Controls="clr-namespace:SLExtensions.Controls;assembly=SLExtensions.C o
ntrols">
    <UserControl.Resources>
        <Data:ResourceSelector x:Key="controlTemplateSelector">
            <ResourceDictionary>
                <DataTemplate x:Key="LoginViewModel">
                    <Border BorderBrush="Black" BorderThickness="1,1,1,1">
                        <Views:LoginView/>
                    </Border>
                </DataTemplate>
                <DataTemplate x:Key="TestViewModel">
                    <Views:TestView />
                </DataTemplate>
            </ResourceDictionary>
        </Data:ResourceSelector>
        <DataTemplate x:Key="controlItemTemplate">
            <ContentControl Content="{Binding}"
                            ContentTemplate="{Binding
Converter={StaticResource controlTemplateSelector}}" />
        </DataTemplate>
    </UserControl.Resources>
    <StackPanel x:Name="LayoutRoot" Background="White">
                <ContentControl  Content="{Binding CurrentViewModel}"
                         ContentTemplate="{StaticResource
controlItemTemplate}" />
    </StackPanel>
</UserControl>


    Reply to author    Forward  
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 Nov 29 2008, 7:33 am
From: "Laurent Bugnion, GalaSoft [MVP]" <laur...@galasoft.ch>
Date: Sat, 29 Nov 2008 13:33:24 +0100
Local: Sat, Nov 29 2008 7:33 am
Subject: RE: [WPF Disciples] Re: Silverlight + MVVM = More questions
I am with Corrado on that one. The idea in Silverlight is a "Page" based
navigation. I put "Page" in quotes because it's actually a UserControl, but
still, the idea is heavily inspired from WPF's navigation service. There are
even frameworks implementing this (see
http://blogs.telerik.com/BoryanaMiloshevska/Posts/08-10-03/Page_Navig...
or_Silverlight_2_RC0.aspx for instance).

Another advantage of having the App taking care of the navigation is that it
is able to read query string parameters or even the parameters entered in
the "object" tag, and so a bookmarked navigation is also easy to implement.

Cheers,
Laurent


    Reply to author    Forward  
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 Nov 29 2008, 3:50 pm
From: "Jeremiah Morrill" <jeremiah.morr...@gmail.com>
Date: Sat, 29 Nov 2008 12:50:33 -0800
Local: Sat, Nov 29 2008 3:50 pm
Subject: Re: [WPF Disciples] Re: Silverlight + MVVM = More questions

Thanks guys.  This surely answers my question on moving from the LoginView
to AnotherView.  But does this navigation method work well on all levels of
the UI?

For an example, say I had a LionView, TigerView and BearView (all with their
complimentary ViewModels).  Now visualize a stereotypical LOB "Page", with a
handful of controls (ie product lists, datagrids).  Say one of these
controls was a 200x200 containing 3 buttons.  Let's call it the ZooView.
When any of these 3 buttons are clicked, it would load up a "LionView",
"TigerView" and so on, within the ZooView.  Of course in this situation I
wouldn't want to navigate to a whole new "RootVisual", just "navigate" one
control to another.

This is all really trivial, but I feel like I "break" the MVVM pattern and
it mutates into some crazy ModelViewPresenter-ish-MVVM monstrosity.  There's
no DataType property on the DataTemplate in SL, so the ResourceSelector from
the SL extensions lib seems to fill the gap in making the SL View more
intelligent as to what DataTemplate (or View) to use with a given ViewModel.

Hope this email wasn't a diaremail =P

-Jer

On Sat, Nov 29, 2008 at 4:33 AM, Laurent Bugnion, GalaSoft [MVP]


    Reply to author    Forward  
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 Nov 29 2008, 4:57 pm
From: "Josh Smith" <flappleja...@gmail.com>
Date: Sat, 29 Nov 2008 16:57:34 -0500
Local: Sat, Nov 29 2008 4:57 pm
Subject: Re: [WPF Disciples] Re: Silverlight + MVVM = More questions

Nice usage of "diaremail"...though I don't think your reply qualifies as
one. :)

There are two pieces to this puzzle, imo.  One piece decides *what* to show,
the other piece decides *how* to show it.  I think the first piece is
properly handled in the ViewModel, as you suggested.  The second piece
should be handled as a platform-level service, like typed DataTemplates in
WPF.  However, as you pointed out, since SL doesn't have this, I think using
an extension class is ideal.

What you're describing makes sense to me.  What exactly is the problem that
you are concerned about?

Josh

On Sat, Nov 29, 2008 at 3:50 PM, Jeremiah Morrill <


    Reply to author    Forward  
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 Nov 29 2008, 6:34 pm
From: "Jeremiah Morrill" <jeremiah.morr...@gmail.com>
Date: Sat, 29 Nov 2008 15:34:07 -0800
Local: Sat, Nov 29 2008 6:34 pm
Subject: Re: [WPF Disciples] Re: Silverlight + MVVM = More questions

I was looking for validation of my approach...I'd hate to have to unlearn
anything ;).  All the MVVM SL examples I've looked at, have a single "Page"
with a VM and maybe an ItemsControl/Panel or ListBox, that would be
databound to a collection of VMs.  I have not seen an MVVM example showing
how to dynamically change specific controls in the View *from* the
ViewModel.  I was starting to clutter my View's codebehind to handle a lot
of that, so thats why I said it started being like the MVP/MVVM hybrid...and
it surely didn't look as clean as a WPF MVVM.

My main concern, was that life seemed good with a 3rd party solution...which
makes me sometimes think I'm not leveraging the framework I'm using
correctly.  And also wondering how anyone else does stuff like this within
their own applications.

Thanks all...I feel like I'm well on my way to MVVM nirvana in SL.

-Jer


    Reply to author    Forward  
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 Nov 29 2008, 8:58 pm
From: "Mike Brown" <mbrow...@gmail.com>
Date: Sat, 29 Nov 2008 20:58:12 -0500
Local: Sat, Nov 29 2008 8:58 pm
Subject: Re: [WPF Disciples] Re: Silverlight + MVVM = More questions

I don't know if this trick will work in Silverlight but one technique I used
in WPF was to have a Control as a place holder and used a trigger to change
the template (and thus contents) of the control based on what object I
wanted to display. I used it similar to your "Zoo" scenario, where there
were multiple classes of objects that I wanted to perform the same operation
upon. I never wrote about the technique because I wasn't sure if it
qualified as very useful or not. But since it seems someone else can use it,
I can give a quick post about it.

On Sat, Nov 29, 2008 at 6:34 PM, Jeremiah Morrill <

...

read more »


    Reply to author    Forward  
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 Nov 29 2008, 9:14 pm
From: "Jeremiah Morrill" <jeremiah.morr...@gmail.com>
Date: Sat, 29 Nov 2008 18:14:28 -0800
Local: Sat, Nov 29 2008 9:14 pm
Subject: Re: [WPF Disciples] Re: Silverlight + MVVM = More questions

I think triggers are pretty limited in SL 2.0.  AFAIK, there are only event
triggers, but you can't define your own routed events.  Not sure that can be
implemented without some home-brew infrastructure.  This SL Extension
library has the makings of a routed event framework, but I have yet to try
it on.

-Jer

...

read more »


    Reply to author    Forward  
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 Nov 29 2008, 9:19 pm
From: "Mike Brown" <mbrow...@gmail.com>
Date: Sat, 29 Nov 2008 21:19:09 -0500
Local: Sat, Nov 29 2008 9:19 pm
Subject: Re: [WPF Disciples] Re: Silverlight + MVVM = More questions

So there are no DataTriggers in Silverlight? WTF! Who dropped the ball on
that one?

On Sat, Nov 29, 2008 at 9:14 PM, Jeremiah Morrill <

...

read more »


    Reply to author    Forward  
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.
Paul Stovell  
View profile  
 More options Nov 29 2008, 10:59 pm
From: "Paul Stovell" <stov...@gmail.com>
Date: Sun, 30 Nov 2008 13:59:08 +1000
Local: Sat, Nov 29 2008 10:59 pm
Subject: Re: [WPF Disciples] Re: Silverlight + MVVM = More questions

The same guy who also removed:

   - Triggers
   - Element binding
   - Relative source binding
   - TypeDecriptors
   - Dependency property inheritance
   - Template binding to attached DP's
   - Ability to subscribe to Changed events on DP's

But they gave us a DataGrid, so it's OK :)

...

read more »


    Reply to author    Forward  
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 Nov 29 2008, 11:01 pm
From: "Mike Brown" <mbrow...@gmail.com>
Date: Sat, 29 Nov 2008 23:01:51 -0500
Local: Sat, Nov 29 2008 11:01 pm
Subject: Re: [WPF Disciples] Re: Silverlight + MVVM = More questions

Oh...well that makes up for everything :|

...

read more »


    Reply to author    Forward  
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 Nov 29 2008, 11:29 pm
From: "Jeremiah Morrill" <jeremiah.morr...@gmail.com>
Date: Sat, 29 Nov 2008 20:29:34 -0800
Local: Sat, Nov 29 2008 11:29 pm
Subject: Re: [WPF Disciples] Re: Silverlight + MVVM = More questions

Whomever, "that guy" is...He's a brave one.  It takes a lot of guts to
remove all those and laugh at the thought of rabid developers hunting
him/her down.  ;)

I still feel there's *a lot* of bang for the *buck* in SL.  Even with my
initial frustrations, I was able to talk myself off the ledge by chanting
"At least its not ActionScript...At least its not ActionScript...".  =P

-Jer

...

read more »


    Reply to author    Forward  
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 Nov 30 2008, 12:33 am
From: "Corrado Cavalli" <corradocava...@gmail.com>
Date: Sun, 30 Nov 2008 06:33:44 +0100
Local: Sun, Nov 30 2008 12:33 am
Subject: RE: [WPF Disciples] Re: Silverlight + MVVM = More questions

Add MarkupExtension class J

-Corrado

From: wpf-disciples@googlegroups.com [mailto:wpf-disciples@googlegroups.com]
On Behalf Of Paul Stovell
Sent: domenica 30 novembre 2008 04:59
To: wpf-disciples@googlegroups.com
Subject: [WPF Disciples] Re: Silverlight + MVVM = More questions

The same guy who also removed:

*       Triggers
*       Element binding
*       Relative source binding
*       TypeDecriptors
*       Dependency property inheritance
*       Template binding to attached DP's
*       Ability to subscribe to Changed events on DP's

But they gave us a DataGrid, so it's OK :)

On Sun, Nov 30, 2008 at 12:19 PM, Mike Brown <mbrow...@gmail.com> wrote:

So there are no DataTriggers in Silverlight? WTF! Who dropped the ball on
that one?

On Sat, Nov 29, 2008 at 9:14 PM, Jeremiah Morrill

<jeremiah.morr...@gmail.com> wrote:

I think triggers are pretty limited in SL 2.0.  AFAIK, there are only event
triggers, but you can't define your own routed events.  Not sure that can be
implemented without some home-brew infrastructure.  This SL Extension
library has the makings of a routed event framework, but I have yet to try
it on.

-Jer

On Sat, Nov 29, 2008 at 5:58 PM, Mike Brown <mbrow...@gmail.com> wrote:

I don't know if this trick will work in Silverlight but one technique I used
in WPF was to have a Control as a place holder and used a trigger to change
the template (and thus contents) of the control based on what object I
wanted to display. I used it similar to your "Zoo" scenario, where there
were multiple classes of objects that I wanted to perform the same operation
upon. I never wrote about the technique because I wasn't sure if it
qualified as very useful or not. But since it seems someone else can use it,
I can give a quick post about it.

On Sat, Nov 29, 2008 at 6:34 PM, Jeremiah Morrill

<jeremiah.morr...@gmail.com> wrote:

I was looking for validation of my approach...I'd hate to have to unlearn
anything ;).  All the MVVM SL examples I've looked at, have a single "Page"
with a VM and maybe an ItemsControl/Panel or ListBox, that would be
databound to a collection of VMs.  I have not seen an MVVM example showing
how to dynamically change specific controls in the View *from* the
ViewModel.  I was starting to clutter my View's codebehind to handle a lot
of that, so thats why I said it started being like the MVP/MVVM hybrid...and
it surely didn't look as clean as a WPF MVVM.

My main concern, was that life seemed good with a 3rd party solution...which
makes me sometimes think I'm not leveraging the framework I'm using
correctly.  And also wondering how anyone else does stuff like this within
their own applications.

Thanks all...I feel like I'm well on my way to MVVM nirvana in SL.

-Jer

On Sat, Nov 29, 2008 at 1:57 PM, Josh Smith <flappleja...@gmail.com> wrote:

Nice usage of "diaremail"...though I don't think your reply qualifies as
one. :)

There are two pieces to this puzzle, imo.  One piece decides what to show,
the other piece decides how to show it.  I think the first piece is properly
handled in the ViewModel, as you suggested.  The second piece should be
handled as a platform-level service, like typed DataTemplates in WPF.
However, as you pointed out, since SL doesn't have this, I think using an
extension class is ideal.

What you're describing makes sense to me.  What exactly is the problem that
you are concerned about?

Josh

On Sat, Nov 29, 2008 at 3:50 PM, Jeremiah Morrill

<jeremiah.morr...@gmail.com> wrote:

Thanks guys.  This surely answers my question on moving from the LoginView
to AnotherView.  But does this navigation method work well on all levels of
the UI?

For an example, say I had a LionView, TigerView and BearView (all with their
complimentary ViewModels).  Now visualize a stereotypical LOB "Page", with a
handful of controls (ie product lists, datagrids).  Say one of these
controls was a 200x200 containing 3 buttons.  Let's call it the ZooView.
When any of these 3 buttons are clicked, it would load up a "LionView",
"TigerView" and so on, within the ZooView.  Of course in this situation I
wouldn't want to navigate to a whole new "RootVisual", just "navigate" one
control to another.  

This is all really trivial, but I feel like I "break" the MVVM pattern and
it mutates into some crazy ModelViewPresenter-ish-MVVM monstrosity.  There's
no DataType property on the DataTemplate in SL, so the ResourceSelector from
the SL extensions lib seems to fill the gap in making the SL View more
intelligent as to what DataTemplate (or View) to use with a given ViewModel.

Hope this email wasn't a diaremail =P

-Jer

On Sat, Nov 29, 2008 at 4:33 AM, Laurent Bugnion, GalaSoft [MVP]

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

I am with Corrado on that one. The idea in Silverlight is a "Page" based
navigation. I put "Page" in quotes because it's actually a UserControl, but
still, the idea is heavily inspired from WPF's navigation service. There are
even frameworks implementing this (see
http://blogs.telerik.com/BoryanaMiloshevska/Posts/08-10-03/Page_Navig...
or_Silverlight_2_RC0.aspx for instance).

Another advantage of having the App taking care of the navigation is that it
is able to read query string parameters or even the parameters entered in
the "object" tag, and so a bookmarked navigation is also easy to implement.

Cheers,
Laurent

...

read more »


    Reply to author    Forward  
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.
Marlon Grech  
View profile  
 More options Nov 30 2008, 2:50 am
From: "Marlon Grech" <marlongr...@gmail.com>
Date: Sun, 30 Nov 2008 08:50:26 +0100
Local: Sun, Nov 30 2008 2:50 am
Subject: Re: [WPF Disciples] Re: Silverlight + MVVM = More questions

they say Silverlight is the little brother of WPF.... apparently from a
different father....

On Sun, Nov 30, 2008 at 5:29 AM, Jeremiah Morrill <

...

read more »


    Reply to author    Forward  
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 Nov 30 2008, 7:08 am
From: "Laurent Bugnion, GalaSoft [MVP]" <laur...@galasoft.ch>
Date: Sun, 30 Nov 2008 13:08:45 +0100
Local: Sun, Nov 30 2008 7:08 am
Subject: RE: [WPF Disciples] Re: Silverlight + MVVM = More questions

I am sworn to secrecy ;) but there is a lot in store for Silverlight 3.
Patience, grasshoppers, patience.

For the records, the story of triggers in SL is as follows:

.         Triggers are apparently really hard to implement, and the team had
to give up.

.         They implemented VSM instead

.         Then they saw that VSM was actually pretty cool

.         So now VSM is going to flow into WPF.

.         Triggers *should* go into SL some day too, but I wouldn't hold my
breath

The only event trigger that is "supported" is the Loaded event, which is
nothing more than a remain from the past (SL1) and so it is recommended not
to use it. I usually prefer to trigger the animations in code.

At least, it's not ActionScript ;)

Laurent

From: wpf-disciples@googlegroups.com [mailto:wpf-disciples@googlegroups.com]
On Behalf Of Marlon Grech
Sent: Sunday, November 30, 2008 8:50 AM
To: wpf-disciples@googlegroups.com
Subject: [WPF Disciples] Re: Silverlight + MVVM = More questions

they say Silverlight is the little brother of WPF.... apparently from a
different father....

On Sun, Nov 30, 2008 at 5:29 AM, Jeremiah Morrill

<jeremiah.morr...@gmail.com> wrote:

Whomever, "that guy" is...He's a brave one.  It takes a lot of guts to
remove all those and laugh at the thought of rabid developers hunting
him/her down.  ;)

I still feel there's a lot of bang for the buck in SL.  Even with my initial
frustrations, I was able to talk myself off the ledge by chanting "At least
its not ActionScript...At least its not ActionScript...".  =P

-Jer

On Sat, Nov 29, 2008 at 7:59 PM, Paul Stovell <stov...@gmail.com> wrote:

The same guy who also removed:

*       Triggers
*       Element binding
*       Relative source binding
*       TypeDecriptors
*       Dependency property inheritance
*       Template binding to attached DP's
*       Ability to subscribe to Changed events on DP's

But they gave us a DataGrid, so it's OK :)

On Sun, Nov 30, 2008 at 12:19 PM, Mike Brown <mbrow...@gmail.com> wrote:

So there are no DataTriggers in Silverlight? WTF! Who dropped the ball on
that one?

On Sat, Nov 29, 2008 at 9:14 PM, Jeremiah Morrill

<jeremiah.morr...@gmail.com> wrote:

I think triggers are pretty limited in SL 2.0.  AFAIK, there are only event
triggers, but you can't define your own routed events.  Not sure that can be
implemented without some home-brew infrastructure.  This SL Extension
library has the makings of a routed event framework, but I have yet to try
it on.

-Jer

On Sat, Nov 29, 2008 at 5:58 PM, Mike Brown <mbrow...@gmail.com> wrote:

I don't know if this trick will work in Silverlight but one technique I used
in WPF was to have a Control as a place holder and used a trigger to change
the template (and thus contents) of the control based on what object I
wanted to display. I used it similar to your "Zoo" scenario, where there
were multiple classes of objects that I wanted to perform the same operation
upon. I never wrote about the technique because I wasn't sure if it
qualified as very useful or not. But since it seems someone else can use it,
I can give a quick post about it.

On Sat, Nov 29, 2008 at 6:34 PM, Jeremiah Morrill

<jeremiah.morr...@gmail.com> wrote:

I was looking for validation of my approach...I'd hate to have to unlearn
anything ;).  All the MVVM SL examples I've looked at, have a single "Page"
with a VM and maybe an ItemsControl/Panel or ListBox, that would be
databound to a collection of VMs.  I have not seen an MVVM example showing
how to dynamically change specific controls in the View *from* the
ViewModel.  I was starting to clutter my View's codebehind to handle a lot
of that, so thats why I said it started being like the MVP/MVVM hybrid...and
it surely didn't look as clean as a WPF MVVM.

My main concern, was that life seemed good with a 3rd party solution...which
makes me sometimes think I'm not leveraging the framework I'm using
correctly.  And also wondering how anyone else does stuff like this within
their own applications.

Thanks all...I feel like I'm well on my way to MVVM nirvana in SL.

-Jer

On Sat, Nov 29, 2008 at 1:57 PM, Josh Smith <flappleja...@gmail.com> wrote:

Nice usage of "diaremail"...though I don't think your reply qualifies as
one. :)

There are two pieces to this puzzle, imo.  One piece decides what to show,
the other piece decides how to show it.  I think the first piece is properly
handled in the ViewModel, as you suggested.  The second piece should be
handled as a platform-level service, like typed DataTemplates in WPF.
However, as you pointed out, since SL doesn't have this, I think using an
extension class is ideal.

What you're describing makes sense to me.  What exactly is the problem that
you are concerned about?

Josh

On Sat, Nov 29, 2008 at 3:50 PM, Jeremiah Morrill

<jeremiah.morr...@gmail.com> wrote:

Thanks guys.  This surely answers my question on moving from the LoginView
to AnotherView.  But does this navigation method work well on all levels of
the UI?

For an example, say I had a LionView, TigerView and BearView (all with their
complimentary ViewModels).  Now visualize a stereotypical LOB "Page", with a
handful of controls (ie product lists, datagrids).  Say one of these
controls was a 200x200 containing 3 buttons.  Let's call it the ZooView.
When any of these 3 buttons are clicked, it would load up a "LionView",
"TigerView" and so on, within the ZooView.  Of course in this situation I
wouldn't want to navigate to a whole new "RootVisual", just "navigate" one
control to another.  

This is all really trivial, but I feel like I "break" the MVVM pattern and
it mutates into some crazy ModelViewPresenter-ish-MVVM monstrosity.  There's
no DataType property on the DataTemplate in SL, so the ResourceSelector from
the SL extensions lib seems to fill the gap in making the SL View more
intelligent as to what DataTemplate (or View) to use with a given ViewModel.

Hope this email wasn't a diaremail =P

-Jer

On Sat, Nov 29, 2008 at 4:33 AM, Laurent Bugnion, GalaSoft [MVP]

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

I am with Corrado on that one. The idea in Silverlight is a "Page" based
navigation. I put "Page" in quotes because it's actually a UserControl, but
still, the idea is heavily inspired from WPF's navigation service. There are
even frameworks implementing this (see
http://blogs.telerik.com/BoryanaMiloshevska/Posts/08-10-03/Page_Navig...
or_Silverlight_2_RC0.aspx for instance).

Another advantage of having the App taking care of the navigation is that it
is able to read query string parameters or even the parameters entered in
the "object" tag, and so a bookmarked navigation is also easy to implement.

Cheers,
Laurent

...

read more »


    Reply to author    Forward  
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 Nov 30 2008, 11:39 am
From: "Mike Brown" <mbrow...@gmail.com>
Date: Sun, 30 Nov 2008 11:39:27 -0500
Local: Sun, Nov 30 2008 11:39 am
Subject: Re: [WPF Disciples] Re: Silverlight + MVVM = More questions

Okay...I guess I have to bite the bullet...

On Sun, Nov 30, 2008 at 7:08 AM, Laurent Bugnion, GalaSoft [MVP]

...

read more »


    Reply to author    Forward  
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.
John Gossman  
View profile  
 More options Nov 30 2008, 4:43 pm
From: "John Gossman" <gossmans...@gmail.com>
Date: Sun, 30 Nov 2008 13:43:58 -0800
Local: Sun, Nov 30 2008 4:43 pm
Subject: Re: [WPF Disciples] Re: Silverlight + MVVM = More questions

WPF was designed and implemented as a core, no-compromise Windows
component.  In order to get a small, portable, factored implementation of
WPF that would work the same on Windows and non-Windows including Mobile
devices that don't even run the CLR, we reimplemented much of the
framework.  We will be adding other WPF features as time goes on.  I wrote
about some of the harder choices here:

http://blogs.msdn.com/johngossman/archive/2008/05/01/silverlight-the-...

...

read more »


    Reply to author    Forward  
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 Nov 30 2008, 7:40 pm
From: "Mike Brown" <mbrow...@gmail.com>
Date: Sun, 30 Nov 2008 18:40:14 -0600
Local: Sun, Nov 30 2008 7:40 pm
Subject: Re: [WPF Disciples] Re: Silverlight + MVVM = More questions

To be honest, I understand fully the sacrifices and decisions that needed to
be made with Silverlight. When I said bite the bullet, I meant I had put off
learning VSM for a while. I'm going to stop procrastinating and spend a good
weekend with SL2U. To be fully honest, I'd prefer to see 3D before
triggers...if the VSM supports a workaround then I'm all for it!

...

read more »


    Reply to author    Forward  
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.
End of messages
« Back to Discussions « Newer topic     Older topic »

Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google