Enable application framework settings in WPF projects? - wpf

What it is the option Enable application framework that I found in Visual Studio under VB.NET WPF projects Application settings?
I found it enabled by default and the "Shutdown mode" configured as "On last windows close". But for me is not really clear what does it mean that setting and also the other settings listed in that combo box.

It means if you have an application that has multiple forms, the application terminates when the last form of that application has been closed. It doesn't matter which form is the last form you close. If you close all forms that belong to that application the application terminates.
"When Startup Form Closes" means that the application terminates when the form that is listed in the "Startup from:" Combobox gets closed. This means if you still have forms open but close the form that was set as your startup form, all other forms get closed aswell and your appliction terminates.

Related

Single Taskbar icon for all Windows in multi process wpf app ( click once deployed)

I have multi process wpf app : 1 master process + 1or more slave process. All these processes have Windows.
Now I have set icon property of all the windows to xyz.ico.
Also I have set ApplicationIcon property of startup project to xyz.ico.
I am deploying the app through click once.
As per my understanding , setting above two icon property should be enough to make sure all windows of all process appear under single Taskbar icon.
But I am seeing that the windows of mater process appear in a Taskbar icon while all other process's windows appear under a different Taskbar icon.
Any idea what am I missing? Or any other technique to achieve this scenario.
Note: I am NOT launching different application. Theres just one app , that app is launching The different processes.
answer: finally we sorted this out using the appUserModelID shell32 APIs. It did work even with click once being used.

CLR exception STAThread attribute required for ElementHost in WinForms app

I have a WinForms VB app, using Visual Studio 2010. I am using the WPF DocumentViewer, so it is hosted by the ElementHost control. In my AppMain_Form.Designer.vb, when the follopwing (generated) statement is executed:
Me.rv_doc_vwr_host = New System.Windows.Forms.Integration.ElementHost()
I get an exception (which I had to enable CLR exceptions for the debugger to get):
"The calling thread must be STA, because many UI components require this."
However, in my research for this problem, I found the following:
1) Windows Forms applications are SingleThreaded by default.
2) The Main procedure is generated automatically for Windows Forms applications, and it is hidden.
3) A Main procedure can be manually coded, but this requires disabling the Application Framework, which I believe is rather necessary for a Windows Forms application.
So, why is this exception occurring if the Windows Forms application is SingleThreaded by default? If not, how can I mark the Main procedure as STAThread if it is hidden? Why did I have to enable CLR exceptions to catch this? Prior to enabling CLR exceptions, this did not show up in my testing, but when I ran my app outside of Visual Studio, it displayed an exception box briefly about creating the main form, but before I could get any details it was replaced by my splash screen, then my main form. The app worked normally after that. However, I cannot deploy it with an exception message being displayed every time it starts up.

How to prevent XBAP Browser application from being closed in a web browser

We are developing a WPF application with a XBAP part running in a web browser, both using Caliburn.Micro framework.
There are no problems with implementation and deployment except that there is a requirement the application should not allow user to close it when instantly when some data was modified on the active window and user did not press save.
In the desktop application it is just easy as overriding Caliburn's CanClose method which itself is a part of Window.Closing callback. This callback is executed and CancelEventArgs.Cancel can be set if necessary.
In the XBAP application, Application.Current.MainWindow is a RootBrowserWindow and when it's Closing and Closed events are subscribed, these never get called even if callback is a static method (I'm modifying Caliburn.Micro code here for testing).
My question is how to prevent WPF XBAP browser application running in Internet Explorer from closing when user tries to close the tab or a whole browser window? Application trust is not an issue as we can (and will) ask clients to give full trust for the app.
Sorry to my knowledge, you can't, IExplorer restrictions. You are not even allowed to check if your window is minimized and even certain key combos isn't allowed in XBAP applications. Fulltrust or not, IE issue :(
I thinkered with the same issue as you about 3-4 years ago, + some keybindings, did alot of interop stuff, to no avail from what I can remember.
Cheers
Stian

Behaviours in wpf apps Microsoft expression blend 4

I am using Microsoft expression blend 4 and i want to add a simple button,in a wpf application, which by clicking it(on "Run Project" mode) navigates the user to another existing wpf application in expression blend 4.This can be done by using a method but maybe I used the wrong method or i used the right method the wrong way.To be more specific i dragged on the button(that i want to make the task i mentioned) the "Launch UriOrFile Action" method but i realised(by making experiments with various files on desktop and using internet url's) that i can only link the running wpf application with random files or internet sites and not to another wpf application as i wanted(when i put the path of the wpf application it pops up a window saying"windows explorer has stopped working",something that didnt occured when i put random file's paths or internet sites url's).If anyone understands my problem let me know!thanks!!
Check out Process.Start. Create a command that fires code that calls that method.

How to have multiple windows in one WPF Application?

I'm relatively new to the WPF world and I'm working on an application where I need to have multiple windows in one application. Like Photoshop when the user clicks on "New" button a new window opens and the old existing window(s) goes in the background. The toolbar and the statusbar, however, stay on top, untouched.
I would also like to add the feature that the user can work with multiple windows if each of them is not maximized.
How do I achieve this?
I apologize if I'm a bit unclear in framing my question.
What you are (probably) talking about is an MDI Application. "Unfortunately" WPF does not support that natively. I use quotes because it is more frowned upon in modern UI development than it was in the past.
Instead, the most common "WPF way" of doing this is to open each New window in a new tab in a tab control (like Visual Studio and most web browsers do).
If you really want to do an MDI application, Google search that, but to warn you, it probably means creating your own Window manager.
An alternative is to open non-modal windows, with their ShowInTaskbar property set to false. This gives you the ability to open as many windows as you want, but you lose the ability to contain them within a centralized workspace app.

Resources