continue to work with WPF, other project types different wpf application startup path to get this code
"AppDomain.CurrentDomain.BaseDirectory"
by Ilyax on 11. December 2010 in Development
continue to work with WPF, other project types different wpf application startup path to get this code
"AppDomain.CurrentDomain.BaseDirectory"
by Ilyax on 25. November 2010 in Development
Today working on WPF, small but significant problem encountered "Dispatcher.CheckAccess()" , walking thread meeting with such an error frustrating if working on WPF not work intellisense .CheckAccess() function but compile the application does not error :) took my time with more than Dispatcher.CheckAccess() work WPF
by Ilyax on 25. August 2010 in Development
WPF project is dynamic startup instance. What does this mean ?
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Test());
}
classic windows form startup function
If your project is WPF application not have program.cs , WPF have (App.xaml and App.xaml.cs)
<Application
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="BlogTestApplication.App"
StartupUri="Test.xaml">
<Application.Resources>
<!-- Resources scoped at the Application level should be defined here. -->
</Application.Resources>
</Application>
standart App.xmal source
look StartupUri="Test.xaml" is your WPF application startup instance WPF is dynamic generate main method if you want can change
StartupUri="Test2.xaml">
Other Method
namespace BlogTestApplication
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}// class end
}
App.xaml.cs standart class structure
Add new method App.xaml.cs
namespace BlogTestApplication
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
void Main(object sender, StartupEventArgs e)
{
Test ttWin = new Test();
ttWin.Show();
}
}// class end
}
change App.xmal attribute
<Application
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="BlogTestApplication.App"
Startup="Main">
<Application.Resources>
<!-- Resources scoped at the Application level should be defined here. -->
</Application.Resources>
</Application>
set main method startup attribute
by Ilyax on 04. July 2010 in Development
When do use Wpf application is thread having "The calling thread must be STA, because many UI components require this"
Sample Code:
Thread thrTest= new Thread(new ThreadStart(YourFunctionName));
thrTest.Start();
build this code not error but runtime "The calling thread must be STA, because many UI components require this"
This Code:
Thread thrTest= new Thread(new ThreadStart(YourFunctionName));
thrTest.SetApartmentState(ApartmentState.STA);
thrTest.Start();
build and no error :)
© Copyright 2007-2010 iLyax.