Closed ghost1372 closed 7 months ago
Okay i would investigate on this later. I think it's always better to have an Application instance in the app. If you need to custom the entry, you can always do something like this:
Program.cs
public static class Program
{
public static App App_Main;
public static AnnotateWindow? Window_Annotate;
[STAThread]
public static void Main(string[] args)
{
App_Main = new App();
App_Main.Run();
}
App.xaml
<Application x:Class="Inkways.Annotator.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Inkways.Annotator"
Startup="Application_Startup" ShutdownMode="OnMainWindowClose">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Inkways.Engine;component/Themes/AppResources.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
App.xaml.cs
public partial class App : Application
{
public App()
{
InitializeComponent();
}
private void Application_Startup(object sender, StartupEventArgs e)
{
//TODO: Do your own things here
Program.Window_Annotate = new AnnotateWindow();
this.MainWindow = Program.Window_Annotate;
Program.Window_Annotate.Show();
}
}
}
Okay i would investigate on this later. I think it's always better to have an Application instance in the app. If you need to custom the entry, you can always do something like this:
Program.cs
public static class Program { public static App App_Main; public static AnnotateWindow? Window_Annotate; [STAThread] public static void Main(string[] args) { App_Main = new App(); App_Main.Run(); }
App.xaml
<Application x:Class="Inkways.Annotator.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:Inkways.Annotator" Startup="Application_Startup" ShutdownMode="OnMainWindowClose"> <Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="/Inkways.Engine;component/Themes/AppResources.xaml"/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Application.Resources> </Application>
App.xaml.cs
public partial class App : Application { public App() { InitializeComponent(); } private void Application_Startup(object sender, StartupEventArgs e) { //TODO: Do your own things here Program.Window_Annotate = new AnnotateWindow(); this.MainWindow = Program.Window_Annotate; Program.Window_Annotate.Show(); } } }
tnx but in my case there is no Program.cs or App
Hi, I have made a commit for UIApplication, can you help me test it out? Thanks
Hi, I have made a commit for UIApplication, can you help me test it out? Thanks
Thank you, i will test it soon
@NotYoojun Thank you issue now has been Fixed🙏👌 let me try more to see if there is other issues or not also i should mention that using following code is not enough and does not work, and we should add resources from code-behind
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ui:ThemeResources />
<ui:XamlControlsResources />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
public MainWindow()
{
Application.Current.Resources.MergedDictionaries.Add(new ThemeResources());
Application.Current.Resources.MergedDictionaries.Add(new XamlControlsResources());
InitializeComponent();
}
Can you send me your project? I'm available to test it now.
I've made another commit 7f405d130202a2ca57419677963da8a41c2d9f9b, can you try that?
Can you send me your project? I'm available to test it now.
I've made another commit 7f405d1, can you try that?
yes, please wait
I've made another commit 7f405d1, can you try that?
we should still using Code-Behind and Xaml both for adding resources
Damn it, no matter how i try, the App.xaml-less project just don't work on my computer anyway. I have no idea how to do this, sorry :(
Damn it, no matter how i try, the App.xaml-less project just don't work on my computer anyway. I have no idea how to do this, sorry :(
using both code-behind and xaml is fine for me and is working, does this work for you? you should add code-behind before initialize... code. if this is working for you i think we can leave this here and we can close this issue.
This doesn'tw work for me. But it's okay, I never code a program with App.xaml anyways. So i guess we can close this issue now.
can you upload a nuget package?
Sure but pls wait for me to finish dinner first.
Sure, take your time. Enjoy your dinner. 😊
There is some type of application which does not have any App.xaml. in this kind of app we can not use this lib because we can not load resources. we only have Window.xaml file and we should add resources in this file. i tried a lot of ways to doing this but all of them failed. there is a lib like this here https://github.com/lepoco/wpfui i could finaly use this lib for my porpuse like this:
i tried something like this for your library and failed. there is some issues in mentioned repo which tell us this issue come from where Application.Current https://github.com/lepoco/wpfui/issues/837 https://github.com/lepoco/wpfui/issues/662 https://github.com/lepoco/wpfui/issues/668