Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Onstartup method in App.xaml.cs

$
0
0

This is my App.xaml.cs I am getting two  windows of the application; one is blank and one with desired o/p (i.e with the binding of ViewModelAdd) please tell me how to get only one start up window is this related to StartupUri in app.xaml?

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using MyFirstExample.ViewModel;

namespace MyFirstExample
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {


        protected override void OnStartup(StartupEventArgs e)
        {


            base.OnStartup(e);
          MainWindow w = new MainWindow();
            ViewModelAdd VM = new ViewModelAdd();
            w.DataContext = VM;
            w.Show();
        }

    }

    }

App.xaml

             <Application x:Class="MyFirstExample.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             StartupUri="MainWindow.xaml">
    <Application.Resources>
         
    </Application.Resources>
</Application>

Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>