Click here to Skip to main content
15,885,897 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: WPF databinding versus dispatcher Pin
Kenneth Haugland16-Oct-13 2:25
mvaKenneth Haugland16-Oct-13 2:25 
GeneralRe: WPF databinding versus dispatcher Pin
GuyThiebaut16-Oct-13 2:44
professionalGuyThiebaut16-Oct-13 2:44 
GeneralRe: WPF databinding versus dispatcher Pin
Kenneth Haugland16-Oct-13 2:51
mvaKenneth Haugland16-Oct-13 2:51 
QuestionWPF Views & ViewModels Question Pin
Kevin Marois14-Oct-13 7:43
professionalKevin Marois14-Oct-13 7:43 
AnswerRe: WPF Views & ViewModels Question Pin
SledgeHammer0114-Oct-13 18:03
SledgeHammer0114-Oct-13 18:03 
GeneralRe: WPF Views & ViewModels Question Pin
Kevin Marois15-Oct-13 7:19
professionalKevin Marois15-Oct-13 7:19 
GeneralRe: WPF Views & ViewModels Question Pin
SledgeHammer0115-Oct-13 10:48
SledgeHammer0115-Oct-13 10:48 
GeneralRe: WPF Views & ViewModels Question Pin
Kevin Marois16-Oct-13 9:16
professionalKevin Marois16-Oct-13 9:16 
Ok, maybe I'm just not seeing it, but I can't find a decent example of this. All the examples I'm finding don't really seem to apply to what I'm doing.

Again, here's the problem I'm trying to solve...

The PC version looks like this[^]

Each 'Center' is essentially more or less the same - a list and tab control which can have any number of the view open. In the image, the Job Center is open with one Job open. The area in red is the JobView. The code in the JobCenter's LoadViiew (see below) method creates an instance of the JobViewModel and JobView, assigned the VM to the View's DataContext, assigns the view to the tab's Content property, and add the tab.

The Tablet's Home[^] is different. It's Job View[^] is much smaller and has less elements.

Here's where my confusion/problem lies...

Both Job views can use the same VM, so the VM is in the shared project.

Both Job views need to open dialogs. For example the Address Editor. In the PC version this is a model dialog. In the Tablet version is will be another 'flat' view that replaces the current view. The user will add or select an address, click Ok, the view goes away and the Job view comes back.


1) What's the right way to load the Address Editor?

2) The Center's all load their child views onto tabs like this:

private void loadView(JobArgs Args)
{
    // Create a View Info instance
    ViewInfo tabInfo = new ViewInfo
    {
        View = View.Job,
        EntityId = Args.Job.JobRevisionId
    };

    if (tabInfo.EntityId > 0 && TabManager.IsTabOpen(tabInfo))
    {
        TabManager.ActivateTab(tabInfo);
    }
    else
    {
        // Create an instance of the job view model and load it
        JobViewModel vm = new JobViewModel();
        vm.Load(Args);

        // Create the view and assign the view model to it
        UserControl view = new JobView();
        view.DataContext = vm;

        // Cretae a tab and assign the presenter view to it
        TabItem tabItem = new TabItem
        {
            Header = vm.GetEntityCaption(), 
            Content = view, 
            Tag = tabInfo
        };

        // Add the tab and activate it
        TabManager.AddTab(tabItem, true);
    }
}



The obvious problem here is that the ViewModel knows about the View.

So how do I have the VM load the right view? regardless of which version I'm in. I'm confused because the VM lives in the Shared project, and the target views are in their own project. We discussed the ViewModelLocator, but I cannot find an example that seems like it works in this scenerio.

I'm guessing the ViewModelLocator's job is to say, "Hey I'm view 'JobView' and I need a view model, so go get it for me"?

While I like the idea, how and where do I handle opening dialogs, if not in the Job's VM?

I'm pretty confused about the right way to open/work with child views.

Let me ask the question this way, so I'm clear...

In the PC version, when the New button is clicked in the JobCenter, I need to add a tab and put a JobView control on a it. I have been doing all of this in the VM, but it's wrong. What is the right way to do this? An example would be great, if you know of one.

Thanks
If it's not broken, fix it until it is

GeneralRe: WPF Views & ViewModels Question Pin
SledgeHammer0116-Oct-13 10:01
SledgeHammer0116-Oct-13 10:01 
GeneralRe: WPF Views & ViewModels Question Pin
Kevin Marois16-Oct-13 11:10
professionalKevin Marois16-Oct-13 11:10 
GeneralRe: WPF Views & ViewModels Question Pin
SledgeHammer0116-Oct-13 17:41
SledgeHammer0116-Oct-13 17:41 
GeneralRe: WPF Views & ViewModels Question Pin
SledgeHammer0116-Oct-13 10:09
SledgeHammer0116-Oct-13 10:09 
Questionaccessing remote system Pin
Arun kumar Gautam9-Oct-13 23:18
Arun kumar Gautam9-Oct-13 23:18 
AnswerRe: accessing remote system Pin
Richard MacCutchan9-Oct-13 23:25
mveRichard MacCutchan9-Oct-13 23:25 
GeneralRe: accessing remote system Pin
Arun kumar Gautam9-Oct-13 23:43
Arun kumar Gautam9-Oct-13 23:43 
GeneralRe: accessing remote system Pin
Richard MacCutchan10-Oct-13 0:07
mveRichard MacCutchan10-Oct-13 0:07 
AnswerRe: accessing remote system Pin
mohitsaxena110-Oct-13 7:50
professionalmohitsaxena110-Oct-13 7:50 
GeneralRe: accessing remote system Pin
Arun kumar Gautam11-Oct-13 7:00
Arun kumar Gautam11-Oct-13 7:00 
GeneralRe: accessing remote system Pin
Richard MacCutchan11-Oct-13 7:46
mveRichard MacCutchan11-Oct-13 7:46 
QuestionBinding converter in code behind Pin
USAFHokie804-Oct-13 2:24
USAFHokie804-Oct-13 2:24 
AnswerRe: Binding converter in code behind Pin
Richard Deeming4-Oct-13 3:02
mveRichard Deeming4-Oct-13 3:02 
AnswerRe: Binding converter in code behind Pin
USAFHokie804-Oct-13 3:24
USAFHokie804-Oct-13 3:24 
GeneralRe: Binding converter in code behind Pin
Richard Deeming4-Oct-13 3:34
mveRichard Deeming4-Oct-13 3:34 
AnswerRe: Binding converter in code behind Pin
mohitsaxena110-Oct-13 8:04
professionalmohitsaxena110-Oct-13 8:04 
Questionvalidation for 2 DateTimePicker (start date and end date) in WPF Pin
Yogi_vns0073-Oct-13 2:04
Yogi_vns0073-Oct-13 2:04 

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.