How can hide the opened child windows from taskbar (WPF)? - c#

How can hide the opened child windows from taskbar when I am showing and hiding the child windows even when I hide the child window the hidden window still appear in the taskbar WPF?
Thanks in advance,
Here is an Example how I show the dialogs:
AlignLocalAxisView alignLocalAxisView = Container.Resolve<AlignLocalAxisView>
(new ParameterOverride("model", AttributesSelectedItems));
OpenedWindowView = alignLocalAxisView;
alignLocalAxisView.Show();

There should be a ShowInTaskbar property for the window.
If your window is defined in XAML, you can set the property deliberately as shown below:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="MyApplication.MainWindow"
Title="MainWindow"
Height="350" Width="425"
ShowInTaskbar="False">
You can also set this in your code behind:
this.ShowInTaskbar = false;
This is also applciable to a window created in code behind when called by name.
Window myNewWindow = new Window();
//Set the property to keep the window hidden in the task bar
myNewWindow.ShowInTaskbar = false;
//Then, show the window
myNewWindow.Show();
EDIT: Based on your example code, the following should work
AlignLocalAxisView alignLocalAxisView = Container.Resolve<AlignLocalAxisView>(new ParameterOverride("model", AttributesSelectedItems));
OpenedWindowView = alignLocalAxisView;
//Assuming your view extends the Window class, the following will work
alignLocalAxisView.ShowInTaskbar = false;
alignLocalAxisView.Show();
Hopefully, this will be enough to sort the problem out.
For future reference though, this was a fairly quick solution to look up on google - its generally worth searching for an answer first as it can sometimes be a faster way to solve the problem.
in this case, I reworded your issue to "hide task bar icon for window in wpf". The child window part wasn't really needed in the search, as all windows in WPF are basically the same.
I hope that's of some help.

Related

How to change the top-left icon on a ShDocVW C# window

First of all, I am a real newbie to programming in Visual Studio. That being said, I have created a small program that pops up an Internet Explorer window; I now want to replace the Internet Explorer icon in the top-left corner with the project's icon.
Currently, I am opening the window in C#, using the ShDocVw object:
static void Main(string[] args)
{
SHDocVw.InternetExplorer IE = new SHDocVw.InternetExplorer
{
AddressBar = false,
MenuBar = false,
StatusBar = false,
ToolBar = 0,
Visible = true,
Height = 768
};
IE.Navigate2("http://someURL/page.aspx");
}
What I want to replace is the IE icon in the top-left corner (see included picture). The icon is in my project as a resource, and appears on the .exe.
Screen capture of IE header
Is there a way to change the browser icon here?
After checking the SHDocVw InternetExplorer Interface and test it on my side, it seems that there is no way to change the IE window icon on the left via the SHDocVw library.
From your description, I suggest you could try to create a WPF or Windows Forms application, then use the WebView or WebView2 control to display the web content. In this scenario, you could add the custom icon for the WPF or Windows Forms window. screenshot like this:
About how to set the window icon, please refer to the following methods:
To the WPF application, try to use the following code (set the Icon property):
<Window x:Class="WpfApp1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp1"
mc:Ignorable="d"
Icon="favicon.ico"
Title="MainWindow" Height="450" Width="800">
<Grid>
</Grid>
</Window>
More detail information, please check Setting the application icon in WPF
To the Windows Form application.
Right click the Form, in the Properties , it contains the Icon property, click the ... button to select icon.

disable maximize capacity in a wpf window

I'm trying to disable the maximize capacity (not the maximize button) in a wpf window, but so far nothing has succeded.
I'm using a window with WindowStyle="none", but when I drag the window to the far top of the screen, the OS "maximizes" the window (terribly bad, by the way).
I uploaded 3 pictures to show what is happening exactly.
(however, due to the fact that I don't have 10 reputation, I have to post the links instead. Sorry about that. And I can't put all 3 links, only 2 of them, but the first one is just of the window working normally)
During:
After:
use the window state change event:
private void Window_StateChanged(object sender, EventArgs e)
{
if (this.WindowState == System.Windows.WindowState.Maximized)
{
this.WindowState = System.Windows.WindowState.Normal;
}
}
Set MaxHeight,MinHeight and MaxWidth,MinWidth property for the window.
Example
<Window x:Class="test.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" MaxHeight="350" MaxWidth="525" MinHeight="350" MinWidth="525">
</Window>
How do you disable Aero Snap in an application?

How to close a usercontrol in the behind file?

I am new to WPF so please understand:
I have a class of usercontrol that implements a screen (dialog) with a grid that contains controls. My code behind file performs a series of checks prior to opening the dialog. If the conditions aren't met, I want to destroy/exit/unload/close the usercontrol. I am using Windows and it seems that I cannot find the call to close the usercontrol. I read up on the questions that had answers such as closing from the parent... however when I try to find the parent via this.Parent, it returns null.
Any advice?
If your conditions aren't met, and you don't even show the usercontrol - don't initialize it.
If you can't avoid that, you have the option of calling Dispose() or letting the GC handle it.
To get the parent from a usercontrol I use this
var parentWindow = Window.GetWindow(this);
But I agree with Andreas if the conditions are not met don't even load it.
A thought could you bind the grids contents remove the usercontrol from the bound object maybe .
Jim
I am guessing you have added your user control in the xaml. That is why you need to even worry about unloading it. Try loading it in the code instead. have a container in your xaml such as a stack panel to hold the user control.
And do not load it unless you conditions aren't met.
eg:
xaml;
<UserControl x:Class="UserControl2"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300"
>
<Grid>
<StackPanel x:Name="mypanel">
</StackPanel>
</Grid>
</UserControl>
code;
if(conditions are true) then
Dim myusercontrol = New ucMyControl()
Me.mypanel.Children.Add(myusercontrol)
end if

NavigationWindow class: remove navigation bar and maximized NavigationWindow

excuse me for my bad English.
I know that many conversations were made ​​for this type of problem but none answer my specific problem...
I am currently improving a Wpf Application coded in C # and xaml in Microsoft Visual Studio Express 2012 for Windows Desktop.
I would like to remove the navigation bar at the top of my window and maximize it. In my xaml file I do:
NavigationWindow x:Class="WpfAppTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
WindowState="Maximized"
WindowStyle="None"
Title="MainWindow" Height="980 " Width="540" Source="Home.xaml" />
Despite WindowState= "Maximized" and WindowStyle="None" the navigation bar is still displayed and the window is still small. I followed several tutorials that removed the navigation bar, but they used a Window class. I did some tests on a new project by creating a class Window and I can well maximize and remove the navigation bar from my window.
But in my case I need to improve an application in progress but the main window type is MainWindow
Indeed the source Source= "Home.xaml" is no longer recognized after the change Navigation Window to Window. My application contains several pages and I must navigate through it so I have to keep my "Home" type "page" page: <Pagex:Class = "WpfAppTest.Home".
Do you have any idea where my problem may be?
Thanks you in advance.
Geoffrey
You can host a Frame in your Window. That is essentially what a NavigationWindow does.
MSDN has more info on navigation hosts.

Window.Show() Not Showing Windows

I have a slight issue creating a new window. The weird part is that the window seems to be created, but calling .Show() or .Activate() does nothing.
The code I'm using to create the window is:
TicketView tv = new TicketView();
tv.Activate();
I was originally trying to set the data context of the window at the same time, but I've taken that out to see if it was the issue, but I'm still seeing the same behaviour. Regardless, that's what the code is at this time. If anybody has any ideas, I'd be very grateful!
For reference - This is the ticket view XAML
<Window x:Class="Helpdesk.View.TicketView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="TicketView" Height="300" Width="300">
<Grid>
</Grid>
</Window>
It depends on what you are trying to do. What I have done in the past if it is my main window is to use the Application.Run method. If I am trying to run another window from my application I use the ShowDialog method.

Categories