I have a WPF application which behaves weird when another application is also opened. 'Another' application is developed using Panther. WPF apps behaves correctly with all other apps in the machine.
While both the applications opened, and when we click next on the WPF app, the app getting minimized even though its active as per windows active event.
WPF application is built using galasoft and follows slightly different approach in navigation compared to the pattern available when we search.
We initiate the Page from app.xaml.cs and based on the click, we invoke currentPage.Hide() and nextPage.Show() methods. All the navigations are written within App.xaml.cs file. Through a delegate the button click will be passed to app.xaml.cs file and the pages are switched.
Did anyone else face similar kind of issues?
Finally, I managed find an answer/work around to this issue.
In the existing design, the sequence of actions were Hide() the current view and Show() the next view.
Now, we modified the sequence to perform Show() the next screen first and then hide() the current screen. This way, the window was kept active and was visible to the user.
Related
I am developing a banking application for Windows Phone 8.1 RT. For security reason I need to grey out or show an image in my application when it goes background.
It's like when application is running user presses windows button then press and hold back button at that time application's current page is visible. I need to show a image on that view.
When application is running if user press and hold back button at that time also irrespective of page I need to grey my application or show an image.
I have tried changing the opacity of frame in On suspending event it is not reflecting. I have also tried in Window visibility changed event changing the opacity of Window.Content but it's not working too.
Please help me with some pointers on how to achieve this.
There isn't a good way to do this. The app doesn't suspend until several seconds after it has left the screen, so it is too late for the app to change its UI then. Window.Activated would be closer, but is still too late.
ApplicationView.IsScreenCaptureEnabled will prevent capturing a screenshot of the page either in the app or on the task switcher page, but won't prevent the image from showing at all.
The least bad may be to call Application.Current.Exit to close the application completely when deactivated. This is generally a user unfriendly idea, but it will remove the app from the task switcher one it closes (it will probably show up briefly first though).
You can post feature requests on http://wpdev.uservoice.com
I am working on a project that simulates a company's program for performing various functions within a GUI (using C# on VS2010). Currently there are about 10 or so different forms, one for each function (serving as a menu, filling out assorted forms, management of said forms, ect). So far we've been using things along the line of:
Form1 myForm1 = new Form1();
myForm1.Show();
to open new screens and
this.Hide();
when finished with the currently active form. (this.Close() just seems to close the entire program)
This causes some issues in that the process has an issue of continuing to run after the X at the top right of the form is clicked (I think that this is due to hidden forms not being closed properly). I also suspect that if a user uses in-program navigation without killing the process long enough, the constant generation and hiding of forms will end up hogging up all the memory.
In the wild, I rarely see programs that rely on opening new windows/forms constantly to enable user navigation. Programs, such as an installer, typically use an event of some sort to cause the current displayed content to disappear and new content to appear without changing to a new form/window. How can I go about doing this? Is it a matter of having buttons/textboxes/labels all stacked on each other in the one screen, but hidden or is there something more intuitive that I am missing?
Have you looked in to using some kind of MDI setup: http://www.codeproject.com/Articles/7571/Creating-MDI-application-using-C-Walkthrough
The way you can do this (but isn't always feasible) is to make a UserControl for each screen. When its time to move on to the next screen, you simply hide the current user control and show the next one. So if you have 8 screens for example, you make each one into a user control.
Then on your MainForm's Load event, you initially hide all except the first one. When its time to move onto the second screen, you hide the first control and show the second, etc etc
I'm creating a log system ('outside' the application) that logs all the click on the application. I have setup a PreFilterMessage function wich detects a click from the mouse, but I can't find the control/element that was clicked.
I've tried with Mouse.DirectlyOverbut the element is always null.
I've tried also with VisualTreeHelper.HitTest but I don't have a Visualto make the search from.
I don't have access to the inside of the application: only to the Main method (with the Application.Run(new MainForm()); and my Application.AddMessageFilter(new Logger());).
Does anyone have an idea (or a walk around) on how to get the clicked control in the application (in .Net 3.5)?
I've been using an amazing little application called Snoop for some time now that I think does exactly what you're after, it's open source (C#) and may be of use to you if you can find out how it works. (All WPF developers should get this and no I don't work on Snoop lol)
http://snoopwpf.codeplex.com/
I am trying to create a parent WPF/surface application which will host multiple WPF/surface applications. I am looking for some pointers of how to implement such functionality. Was reading http://msdn.microsoft.com/en-us/library/ms742522.aspx but it talks about hosting Win32 content in WPF and vice versa.
My idea is to have something similar to MDI forms where you have a main form and you can instantiate multiple child forms.
In my case, these would be different applications which will be launched using a config file and loaded within the main application.
Also, since is there a way to ensure that the main window's process memory is not hogged by the child process initiated.
Edit:
The host application will launch different applications based on what user selects. One can say its like an application launcher which are build on WPF/Surface touch SDK. Now once the application is launched the launcher goes in the background(except showing small button to bring it forward again at some point later) and when the user ends the current application launcher comes back again in foreground. The only interaction i feel which is necessary is knowing the launched application is terminated or invoking applications in a limited screen area. If someone has seen the Microsoft surface application launcher, even when the application is launched there are corner buttons which bring the app launcher to foreground.
I would first look at using Microsoft Prism, specifically the Modularity namespace.
Except for the "different applications" part, it sounds like a classic case for MVVM. Are these "different applications" actually separate applications, or could they simply be separate projects within the same application? That may simplify the choice of presentation.
I suppose you could still have a View called "Host" that presents a different app.
Of course, WPF doesn't have the concept of MDI, but you can open multiple, non-modal windows.
It really depends on what you mean by "hosting". Does the main window need to somehow handle and/or interact with the other applications, or is it just a launching pad for other applications?
I followed this approach to solve this problem. The launcher was not hosting the application within itself but would launch a new application and hide itself.
Steps I followed:
The main launcher application will run in Kiosk mode i.e always on top/no option to close by capturing the close event/No instance shown in taskbar/no title bar/killing the explorer.exe/hiding the taskbar.
The launcher populates a horizontal listbox (data templated for UI) which lets occupied main center area of screen and can be scrolled either ways.
When user selected an item on listbox, click/tap event a separate process is launched with launcher window's visibility set to hidden and a small button(basically a window with just a button inside and size set to height/width of button) created on the either corner of the screen with always on top option.
The functionality of button is to minimize the current working application and set visibility of launcher back to visible and setting the focus to this window.
Since the process is launched by launcher, i trap the close event for the launched window to know user ended the application and then again pop up the launcher back.
So I would consider myself a .Net and ASP.NET pro but I am a bit new to Windows Mobile (I am targeting .net 3.5 CF and Windows Mobile 6).
I am creating a data driven application that will have 3-4 tables. I have created a form for each table that allows the user to search through the table.
Each form inheretes from the Main form so that they each have the same Menu.
My question is how do I make sure that only one Window is open. I want to allow the user to go to the menu and choose a table which will open a new form. What I don't want is for the user to open say each form and then when they are done to have to close 3 or 4 windows. Is this possible? If so how do I do it? On a side note is there a better way to do this. I don't want all my logic on one form. So I don't just want to hide and show and panels.
I keep something I call an application hub that everything goes though.
So each menu click will call the applciation hub, and each form will reference it.
Then, when switching form, the application hub needs to keep track of the current form, close it, then load the requested form.
This isn't much code to write, and performs well.
Or...performance wise, keep the application hub idea, and keep the dialogs open. It will perform better that way, rather than having to reload the forms all the time.
Then on shut down, the application hub can check which forms are open (it should have a reference to each running form) and close them for the user.
Instead of having multiple Forms (inherited form mainForm) you could put the table stuff on UserControls and have total control about their Creation/Destruction/Visibility much easier.
Use an Interface or a BaseUserControl to implement common functionality.
This article, while not exactly what you are asking, was very helpful when I was redesigning a .NET CF application: Creating a Multiple Form Application Framework for the .NET Compact Framework
My application required a bit of both worlds - I wanted to have a single form open, but also sometimes wanted to stack a secondary form on top of the first (eg. if they go to a Prefs page or some other type of form where they should only ever dismiss it after a moment).
(Pseudo-coding after this)
I created a ViewManager and implemented it as a singleton. When the app first launches, I call ViewManager.GotoForm(frm). This sets the current form to be whatever form I need.
Then I immediately call ViewManager.CurrentForm.ShowDialog() - I'm sure there's a better way, but I found I had to call ShowDialog() at SOME point just to get a form to appear.
Subsequent calls to ViewManager can take the form .ReplaceForm or .StackForm. The differences should be fairly intuitive.
What you can also do in a view manager like this is cache forms that aren't being displayed, but probably will be again and have expensive setup costs (for instance, in a data-driven app you might have to query the database to determine the fields or tables to display on a form, and this won't change at runtime).
The trick here is that you never call .Show() or .ShowDialog() anywhere in your application - you route all form navigation through the view manager which handles loading the next instance of your form, disposing of old forms (if not being cached), and dispatching any sort of populate logic if you want to pass new data to a form's UI before it loads.