Click here to Skip to main content
15,879,093 members
Articles / Programming Languages / C#

Open Child Window in MVVM environment

Rate me:
Please Sign up or sign in to vote.
4.56/5 (10 votes)
14 May 2012CPOL2 min read 60.4K   1.7K   12  
How to open pop up window in MVVM environment. You can use it in WPF or Silverlight.
  • WindowWithMVVM.zip
    • WindowWithMVVM
      • WindowWithMVVM.sln
      • WindowWithMVVM.suo
      • WindowWithMVVM.Web
      • WindowWithMVVM
        • App.xaml
        • App.xaml.cs
        • Assets
        • Bin
          • Debug
            • AppManifest.xaml
            • ar
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • bg
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • ca
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • cs
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • da
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • de
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.ServiceModel.DomainServices.Client.resources.dll
              • System.ServiceModel.DomainServices.Client.Web.resources.dll
              • System.ServiceModel.Web.Extensions.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Navigation.resources.dll
              • System.Windows.Controls.resources.dll
            • el
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • es
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.ServiceModel.DomainServices.Client.resources.dll
              • System.ServiceModel.DomainServices.Client.Web.resources.dll
              • System.ServiceModel.Web.Extensions.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Navigation.resources.dll
              • System.Windows.Controls.resources.dll
            • et
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • eu
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • fi
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • fr
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.ServiceModel.DomainServices.Client.resources.dll
              • System.ServiceModel.DomainServices.Client.Web.resources.dll
              • System.ServiceModel.Web.Extensions.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Navigation.resources.dll
              • System.Windows.Controls.resources.dll
            • he
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • hr
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • hu
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • id
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • it
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.ServiceModel.DomainServices.Client.resources.dll
              • System.ServiceModel.DomainServices.Client.Web.resources.dll
              • System.ServiceModel.Web.Extensions.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Navigation.resources.dll
              • System.Windows.Controls.resources.dll
            • ja
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.ServiceModel.DomainServices.Client.resources.dll
              • System.ServiceModel.DomainServices.Client.Web.resources.dll
              • System.ServiceModel.Web.Extensions.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Navigation.resources.dll
              • System.Windows.Controls.resources.dll
            • ko
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.ServiceModel.DomainServices.Client.resources.dll
              • System.ServiceModel.DomainServices.Client.Web.resources.dll
              • System.ServiceModel.Web.Extensions.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Navigation.resources.dll
              • System.Windows.Controls.resources.dll
            • lt
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • lv
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • ms
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • nl
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • no
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • pl
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • pt
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • pt-BR
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • ro
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • ru
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.ServiceModel.DomainServices.Client.resources.dll
              • System.ServiceModel.DomainServices.Client.Web.resources.dll
              • System.ServiceModel.Web.Extensions.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Navigation.resources.dll
              • System.Windows.Controls.resources.dll
            • sk
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • sl
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • sr-Cyrl-CS
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • sr-Latn-CS
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • sv
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • System.ComponentModel.DataAnnotations.dll
            • System.ComponentModel.DataAnnotations.xml
            • System.ServiceModel.DomainServices.Client.dll
            • System.ServiceModel.DomainServices.Client.Web.dll
            • System.ServiceModel.DomainServices.Client.Web.xml
            • System.ServiceModel.DomainServices.Client.xml
            • System.ServiceModel.Web.Extensions.dll
            • System.ServiceModel.Web.Extensions.xml
            • System.Windows.Controls.Data.DataForm.Toolkit.dll
            • System.Windows.Controls.Data.Input.dll
            • System.Windows.Controls.Data.Input.xml
            • System.Windows.Controls.dll
            • System.Windows.Controls.Navigation.dll
            • System.Windows.Controls.Navigation.xml
            • System.Windows.Controls.xml
            • TestPage.html
            • th
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • tr
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • uk
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • vi
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • WindowWithMVVM.dll
            • WindowWithMVVM.pdb
            • WindowWithMVVM.xap
            • zh-Hans
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.ServiceModel.DomainServices.Client.resources.dll
              • System.ServiceModel.DomainServices.Client.Web.resources.dll
              • System.ServiceModel.Web.Extensions.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Navigation.resources.dll
              • System.Windows.Controls.resources.dll
            • zh-Hant
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.ServiceModel.DomainServices.Client.resources.dll
              • System.ServiceModel.DomainServices.Client.Web.resources.dll
              • System.ServiceModel.Web.Extensions.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Navigation.resources.dll
              • System.Windows.Controls.resources.dll
        • Controls
        • Generated_Code
        • GlobalSuppressions.cs
        • Helpers
        • Libs
          • System.Windows.Controls.Data.DataForm.Toolkit.dll
        • MainPage.xaml
        • MainPage.xaml.cs
        • Models
        • obj
        • Properties
        • ViewModel
        • Views
        • Web
          • Resources
        • WindowWithMVVM.csproj
        • WindowWithMVVM.csproj.user
#pragma checksum "C:\ManojWork\Article\Open Child Window in MVVM environment\WindowWithMVVM\WindowWithMVVM\Views\ErrorWindow.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "98C3E6D9921F0396EF084FE336C11337"
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.239
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Windows;
using System.Windows.Automation;
using System.Windows.Automation.Peers;
using System.Windows.Automation.Provider;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Resources;
using System.Windows.Shapes;
using System.Windows.Threading;


namespace WindowWithMVVM {
    
    
    public partial class ErrorWindow : System.Windows.Controls.ChildWindow {
        
        internal System.Windows.Controls.Grid LayoutRoot;
        
        internal System.Windows.Controls.TextBlock IntroductoryText;
        
        internal System.Windows.Controls.StackPanel ContentStackPanel;
        
        internal System.Windows.Controls.TextBlock LabelText;
        
        internal System.Windows.Controls.TextBox ErrorTextBox;
        
        internal System.Windows.Controls.Button OKButton;
        
        private bool _contentLoaded;
        
        /// <summary>
        /// InitializeComponent
        /// </summary>
        [System.Diagnostics.DebuggerNonUserCodeAttribute()]
        public void InitializeComponent() {
            if (_contentLoaded) {
                return;
            }
            _contentLoaded = true;
            System.Windows.Application.LoadComponent(this, new System.Uri("/WindowWithMVVM;component/Views/ErrorWindow.xaml", System.UriKind.Relative));
            this.LayoutRoot = ((System.Windows.Controls.Grid)(this.FindName("LayoutRoot")));
            this.IntroductoryText = ((System.Windows.Controls.TextBlock)(this.FindName("IntroductoryText")));
            this.ContentStackPanel = ((System.Windows.Controls.StackPanel)(this.FindName("ContentStackPanel")));
            this.LabelText = ((System.Windows.Controls.TextBlock)(this.FindName("LabelText")));
            this.ErrorTextBox = ((System.Windows.Controls.TextBox)(this.FindName("ErrorTextBox")));
            this.OKButton = ((System.Windows.Controls.Button)(this.FindName("OKButton")));
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect
United States United States
Manoj Kumar

AWS Certified Solutions Architect (Web development, Serverless, DevOps, Data)
MSSE - Cloud and Mobile Computing, San Jose State University

A wide range of experience in resolving complex business problems.

* Cloud Technologies: EC2, S3, DynamoDB & RDS databases, Lambda serverless architecture, Microservices architecture, API Gateway, Cloud Front CDN, Linux/Windows systems administration, CloudFormation, DevOps, Docker, CICD, Node.js, Python, Java and other open source technologies. Familiarity with OpenStack.
* Web Technologies: HTML5, Node.Js, MEAN Stack, AngularJS, ASP.Net Core, MVC5, CSS3, jQuery, Bootstrap, MongoDB, JavaScript, JSON, AJAX.
* Data: Experience in database architecture, Big Data, Machine Learning, BI, Data Analytics, No-SQL databases, ETL.
* Mobile: IOS/Android app development

He lives with his wife Supriya and daughter Tisya in Bay Area.

Comments and Discussions