wpf - Is it possible to set the startup form to be a static string value? -


as know can specify view start setting property startupuri below code.

<application x:class="someclass"              xmlns  ="http://schemas.microsoft.com/winfx/2006/xaml/presentation"              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"               startupuri="mainwindow.xaml"              > </application> 

my question: can put in static string value view name, ie. mainwindow.xaml?

i tried below code doesn't work. please share if know how to. thank you!

<application x:class="demo.wpfskill.app"              xmlns  ="http://schemas.microsoft.com/winfx/2006/xaml/presentation"              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"               xmlns:local="clr-namespace:mypublicstaticclassnamespace"               startupuri="{x:static member=local:mypublicstaticclass.astaticvalue}"              > </application> 

edit purpose: put in right name start application in such way not rely on string value.

thanks mzabsky, think better code in code behind below code.

public partial class app : application {     public app()     {         var mainwindow = new mainwindow();         mainwindow.show();     } } 

hope helpful!

you can remove startupuri parameter xaml , open window manually app class c# code.

edit:

example (assuming static value type name of main window class):

public partial class app : application {     public app()     {          window window = (window) activator.createinstance(assembly.getexecutingassembly.gettype(mypublicstaticclass.astaticvalue));          window.show();     } } 

Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -