Not only One window in a wpf Application?

i searched the whole Weekend for examples to handle more than One window in a wpf Application.
All Samples work only with One window. I don’t understand to switch like in Big .Net forms.
Pyxis is to much Code to study, have anyone a Link or example how this is solved ?

Cu
Andreas

I’m not sure if this is what you are looking for but I modified the GHI Cobra graphical demo to show a touch screen calibration window then show the main desktop window once calibration is complete.

It seems all you do is change the mainWindow value of the app.

Basically, when the select button is held, ShowCalibrationWindow is called to display the calibration window. When the calibration is complete, the calibration window calls CalibrationComplete in the Program which then invokes ShowDemo.

Hopefully this shows you how to switch windows:


//---------------------------------------------------------------------------
//                       GHI Electronics, LLC
//                   http://www.ghielectronics.com
//                        Copyright (c) 2010
//                        All rights reserved
//                          EMX Demo V1.01
//---------------------------------------------------------------------------
/*
 * You can use this file if you agree to the following:
 *
 * 1. This header can't be changed under any condition.
 * 2. This is a free software and therefore is provided with NO warranty.
 * 3. Feel free to modify the code but we ask you to provide us with
 *	  any bug reports so we can keep the code up to date.
 * 4. This code may ONLY be used with GHI Electronics, LLC products.
 *
 * THIS SOFTWARE IS PROVIDED BY GHI ELECTRONICS, LLC ``AS IS'' AND 
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
 * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL 
 * GHI ELECTRONICS, LLC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ORT 
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
 *
 *	Specs are subject to change without any notice
 */

using System;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using Microsoft.SPOT.Input;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Touch;
using GHIElectronics.NETMF.Hardware;
using GHIGraphicalDemo.Presentation;

namespace GHIGraphicalDemo
{
    public class Program : Application
    {
        public static Program program;
        private TouchCalibrationPoints touchCalibrationPoints;

        public static void Main()
        {

            bool rebootRequired = false;
            
            if(SetLCDConfigurations())
            { 
                rebootRequired = true;
            }

            if (SetHeapConfigurations())
            {
                rebootRequired = true;
            }

            if (rebootRequired)
            {
                 PowerState.RebootDevice(false);
            }

            Program program = new Program();    

            // Start the application.
            program.Run();
        }

        protected override void OnStartup(EventArgs e)
        {
            // Enable touch
            Touch.Initialize(this);
            TouchCollectorConfiguration.CollectionMethod = CollectionMethod.Native;
            TouchCollectorConfiguration.CollectionMode = CollectionMode.InkAndGesture;

            // Note, this is the amount of time (in ms) to elapse before sending a move event.
            TouchCollectorConfiguration.TouchMoveFrequency = 100; // 10 events a second times a second

            // Create the object that configures the GPIO pins to buttons.
            GPIOButtonInputProvider inputProvider = new GPIOButtonInputProvider(null);

            this.touchCalibrationPoints = TouchCalibrationPoints.Load();

            if (inputProvider.ButtonInitiallyDownValues[Button.VK_SELECT]  || this.touchCalibrationPoints == null)
            {
                this.touchCalibrationPoints = new TouchCalibrationPoints();
                ShowCalibrationWindow();
            }
            else
            {
                this.touchCalibrationPoints.SetCalibration();
                ShowDemo();
            }

        }

        private void ShowCalibrationWindow()
        {
            CalibrationWindow calibrationWindow = new CalibrationWindow(this, this.touchCalibrationPoints);
            ConfigureMainWindow(calibrationWindow);
            this.MainWindow = calibrationWindow;
        }

        public void StartCalibration()
        {
            Touch.ActiveTouchPanel.StartCalibration();
        }

        public void SetCalibration()
        {
            this.touchCalibrationPoints.SetCalibration();
        }

        public void CalibrationComplete()
        {
            this.MainWindow.Close();
            this.touchCalibrationPoints.Save();
            ShowDemo();
        }

        private void ShowDemo()
        {
            Desktop desktop = new Desktop(program);
            ConfigureMainWindow(desktop);
            this.MainWindow = desktop;
        }

        private void ConfigureMainWindow(Window window)
        {
            window.Height = SystemMetrics.ScreenHeight;
            window.Width = SystemMetrics.ScreenWidth;

            // Set the window visibility to Visible.
            window.Visibility = Visibility.Visible;

            // Attach the button focus to the window.
            Buttons.Focus(window);
        }

        static bool SetLCDConfigurations()
        {
            Configuration.LCD.Configurations lcdConfig = new Configuration.LCD.Configurations();
            lcdConfig.Width = 800;
            lcdConfig.Height = 480;

            // Only use if needed, see documentation.
            lcdConfig.PriorityEnable = true;

            lcdConfig.OutputEnableIsFixed = false;
            lcdConfig.OutputEnablePolarity = true;
            lcdConfig.PixelPolarity = false;
            lcdConfig.HorizontalSyncPolarity = false;
            lcdConfig.VerticalSyncPolarity = false;

            // For EMX
            lcdConfig.HorizontalSyncPulseWidth = 150;

            // On ChipworkX, there is a limited range for the HorizontalSyncPulseWidth. Set it to 60 instead.
            // lcdConfig.HorizontalSyncPulseWidth = 60;

            lcdConfig.HorizontalBackPorch = 150;
            lcdConfig.HorizontalFrontPorch = 150;
            lcdConfig.VerticalSyncPulseWidth = 2;
            lcdConfig.VerticalBackPorch = 2;
            lcdConfig.VerticalFrontPorch = 2;
            lcdConfig.PixelClockDivider = 5;

            // Set config
            if (Configuration.LCD.Set(lcdConfig))
            {
                // New settings were saved, must reboot
                // The start-up logo will take effect after the first reset
                Bitmap logo = Resources.GetBitmap(Resources.BitmapResources.logo);
                Configuration.StartUpLogo.Set(logo.GetBitmap(), (int)(lcdConfig.Width - logo.Width) / 2, (int)(lcdConfig.Height - logo.Height) / 2);

                return true;
            }
            else
            {
                return false;
            }
        }

        static bool SetHeapConfigurations()
        {
            if (Configuration.Heap.SetCustomHeapSize(1024*1024*4))
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}

Zoomer please use the code tag.

One thing which was recently released and works fine for multiple windows is glide and you can find it here:
http://www.ghielectronics.com/glide

Ahhh, yes that is much better…

You can download the modified demo which uses my sample code here: http://wiki.tinyclr.com/index.php?title=File:GHI_Cobra_Graphical_Demo_7inch_and_Calibration.zip

thanks, this is exactly what i’m searching for!

Glide is interesting too, but also no example code to find :frowning:
To get started with this only on api code is to hard for me. No feeling for the structure or building of a glide application.

cu
Andreas

You may also try this; it comes with sample apps: http://skewworks.com/products/Pyxis%202

This example is a good starting point:
http://www.ghielectronics.com/glide/example/2/

perfect !!
thank you very much!

cu
Andreas