Here is a Question about WPF Window Control - wpf

ı'am opening a new window in a another window ,but when window1.show()' method is called,
window1 is down in the taskbar with caller window and they is grouping in that task bar,
I click the window1 but not showed the screen,is is still in the task bar...
Why might something like that ?

Unless you specify in Windows 7 that you do not wish to regroup the windows under the same icon, it is not possible per say. The only way I can think of would be to create a new application with that windows instead of opening the window itself., but that would be far fecthed.
Why do you need this ?

Related

Open a copy of the same window using WPF

I am working with a WPF application.I have two text boxes and a button in my first window.Based on some DB operations i need to open the copy of the first window(if possible open like a new tab) provided both windows can be accessed simultaneously.I used
var MainWindow = new MainWindow();
MainWindow.ShowDialog();
and
var MainWindow = new MainWindow();
MainWindow.Show();
both of them doesnt meet my expectations.Can anyone help me.
When you use ShowDialog(), it opens a single modal dialog that is expected to be closed when complete.
If you want to open multiple windows and not block form control, try using Show() instead.
var window = new MainWindow();
window.Show();
I would advise you to read all of the relating pages on MSDN so that you can learn how everything works.
For the Show method:
Opens a window and returns without waiting for the newly opened window to close.
For the ShowDialog method:
Opens a window and returns only when the newly opened window is closed.
From the Remarks section of the Window.Show Method page:
When the Window class is instantiated, it is not visible by default. Show shows a window and returns immediately, without waiting for the window to be closed. Consequently, the opened window does not prevent users from interacting with other windows in the application. This type of window is called a modeless window. Common examples of modeless windows are properties windows, toolboxes, and palettes. To restrict a user to interacting with a specific window, the window must be opened by calling ShowDialog.
Calling Show achieves the same end result as setting Visibility property of the Window object to Visible. However, there is a difference between the two from a timing perspective.
Therefore, for your solution, I would recommend that you use the Show method instead.

Opened windows C# WPF

I have this problem:
In a C# WPF application:
I open a new Window (showOnTaskBar=true, noresize, centered);
From this opened window I open another one that is above the other opened window. The new window is without blue top bar and
showOnTaskbar=false, showDialog();
Everything is ok but if I change the focus, I mean, for example, I open Firefox or another program and then I want to go back to my
opened windows I saw just the first opened window (from step 1) the
other modal window comes up only with ALT+TAB.
So, is there a way to keep both windows always displayed ?
Code to open the second window (from the first normally opened window in step 1):
Form2 form2 = new Form2();
formA2.ShowInTaskbar = false;
form2.ShowDialog();
Thank you,
Adrian
If as I think you have said you are opening the second window from the first, I'm pretty sure you want to try setting the owner of the dialog like this:
form2.Owner = Window.GetWindow(this);
See WPF: How do I set the Owner Window of a Dialog shown by a UserControl?
Hope this helps,
Jay

How to let the parent window of a child window (a.k.a. owned window) stay active with winapi?

I am writing a small C application using winapi. There I've got a window with a child window (toolbox). I am able to keep it inside this window and so on, but my question is: How to keep the main window active, if the child window gets focused?
The main window gets grayed out in this moment.
The windows get created by:
hMainWindow = DialogBoxParam(.......);
hChildWindow = CreateDialogParam(..., hMainWindow, ...);
ShowWindow (hChildWindow, SW_SHOW);
Here a little image of the behaviour of the two windows:
I've found out that simply creating it as WS_CHILD and explicitly NOT as WS_POPUP solves that. It also turns the absolute window coordinates to relative ones so that I dont have to care about the window position anymore by moving the parent window.
// Solved
Create the child window as a modeless dialog box instead of a modal one. So instead of using DialogBox, use CreateDialog
Sorry, that's just the way Windows works: one active window at a time.
You can see this in Visual Studio if you bring up Find and Replace as a tool window, you'll see that it gets activated and the main VS window goes inactive.
Trying to have them both active at the same time could confuse users and accessibility tools like screen readers.

WPF How to get window reference that is loaded from a page that is into it?

I have a page that is into a window similiar to MDI. I want to get the reference of the window in what the page is placed into. The window is loaded.
Thanks.
I'm not 100% sure if I am understanding exactly what you mean.... if you're talking about a Windows Application that where a User Control is situated in a Window, and you want to do something to the Window from the User Control, you can simply do this (in this example it just closes the Window):
Window window = Window.GetWindow(this);
if (window != null)
window.Close();
If this isn't what you meant, could you please post a bit more detail.
I ran into a similar problem and I started with Richard's solution (+1 vote from me!), but I found I had to cast the type to my specific window type to do anything useful.
MainWindow w = (MainWindow)Window.GetWindow(this);
w.method_to_run();

Multiple windows, but also multiple items on the task bar

I'm setting up a program that has three different windows. I'm just using ..
Window1 win1 = new Window1();
win1.show();
...for each of the extra windows. The problem is that each window opens up a new tab on the taskbar. Is there anyway that I can still have my three windows with only one related item on the taskbar?
If possible, I would not like to make them all child forms and have to sit inside of another box.
Thank you
Set the ShowInTaskbar to false
<Window ShowInTaskbar="False" ... />
If you want to make the windows related together, like when you click one of them it brings them all, set the Owner before showing the window (assuming this is your main window)
Window1 w = new Window1();
w.Owner = this;
Set the "secondary" windows' ShowInTaskbar property to false. Also it wouldn't hurt to set their Owner property to App.Current.MainWindow, so that the all the windows close (and hence the application exits) when the main window is closed.

Resources