Click here to Skip to main content
15,886,100 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: WPF databinding versus dispatcher Pin
Mycroft Holmes15-Oct-13 12:40
professionalMycroft Holmes15-Oct-13 12:40 
GeneralRe: WPF databinding versus dispatcher Pin
GuyThiebaut16-Oct-13 2:41
professionalGuyThiebaut16-Oct-13 2:41 
GeneralRe: WPF databinding versus dispatcher Pin
Mycroft Holmes16-Oct-13 12:43
professionalMycroft Holmes16-Oct-13 12:43 
AnswerRe: WPF databinding versus dispatcher Pin
Abhinav S15-Oct-13 18:23
Abhinav S15-Oct-13 18:23 
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 
I have been working on a WPF project. The requirements changed to include a Windows 8 Tablet, so I have created both PC and Win 8 Tablet versions. To do this I split the WPF project into 3:

UI.WPF.PC
Contains the views used in the PC version of the application.

UI.WPF.Tablet
Contains the views used in the Windows 8 Tablet version of the application.

UI.WPF.Shared
Contains the components common to both the PC and Tablet projects. This includes the ViewMmodels.

So far, when a Window needs to open a dialog, I have been doing this from inside the Window's VM:

MaterialSizeEditorViewModel vm = new MaterialSizeEditorViewModel();
vm.Load(args);

MaterialSizeEditorView view = new MaterialSizeEditorView();
view.Owner = engine.MainWindow;
view.DataContext = vm;

view.ShowDialog();


As far as other views, I have done things like this:

protected override void LoadView(View viewType, _ArgsBase args = null)
{
    dynamic vm = null;
    UserControl viewToLoad = null;
    string headerText = string.Empty;

    // If the view is already open, then activate its tab
    if (TabManager.IsTabOpen(viewInfo))
    {
        TabManager.ActivateTab(viewInfo);
    }
    else
    {
        switch (viewType)
        {
            case View.Home:
                headerText = "HOME";
                vm = new TabletHomeViewModel();
                viewToLoad = new TabletHomeView();
                break;

            case View.JobPhases:
                headerText = "JOB PHASES";
                vm = new JobPhaseViewModel();
                viewToLoad = new JobPhaseView();
                break;

            case View.JobAssignments:
                headerText = "JOB ASSIGNMENTS";
                vm = new EmployeeJobAssignmentsViewModel();
                viewToLoad = new EmployeeJobAssignmentsView();
                break;
        }

        if (vm == null)
        {
            return;
        }

        vm.Load(args);
        viewToLoad.DataContext = vm;
    }
}


For data operations, the ViewModels call through a Web API Proxy in an engine class. The engine class is based off an interface with an instance of it passed into the CTOR of each ViewModel, such as:

public JobCenterViewModel(IEngine engine)
    :base(engine)
{
    engine.APIProxy.SomeMethod(some param);
}



The way I'm opening view is clearly wrong. Given the 3 projects, what's the right way to open a view or dialog?
If it's not broken, fix it until it is

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 
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 

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.