NavigationWindow class: remove navigation bar and maximized NavigationWindow - c#

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.

Related

Opening a subwindow as part of the MainWindow

Overview
Hey everyone, I'm working on a project that is a C# WPF desktop app to create and edit a complex system. Simply think of it as and editor that can put together a full description of a car with all it's subcomponents.
I want each different component of the car to have a separate editor window. Like select the painting on the car and tada a sidewindow appears where you can fully customize the car's paint. Then when you click on the engine, that same sidewindow get's replaced by a new editor about the car's engine.
Question
How can I make that editor window that I already created with xaml and codebehind to appear as a part of the MainWindow, embedded as a sidebar?
If possible, I would avoid any 3rd party libraries, but if there is no other 'clean' way of doing it then I'm open to suggestions in that area as well.
I have fully functional windows that I created with the designer, wrote all the code for it to work, now I just have to find a way to embed those into the MainWindow on a press of a button.
Thanks for any answers
If you want something to "part of the MainWindow", you should not create another window because a Window cannot be a child of another element.
What you probably want to do is to move the XAML markup and code-behind from your current subwindow into a UserControl. You can then put the UserControl(s) into an appropriate Panel in your MainWindow.
For example, if you want UserControl to appear a sidebar in the window, you could use a DockPanel to dock it to the right:
<DockPanel>
<Border DockPanel.Dock="Right" Background="Yellow">
<local:SidebarUserControl Margin="10" />
</Border>
<TextBlock>main content...</TextBlock>
</DockPanel>

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

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.

Which is the best way to show another window in wpf mvvm

Hi I got some problem with navigating windows in wpf mvvm. I got two wpf windows, let's say viewA and viewB. all respective view model are bind to the view using prism prism:ViewModelLocator.AutoWireViewModel="True" .
This is my view.
<Window x:Class="eBriefcase.WPF.Views.CaseHearing"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:prism="http://prismlibrary.com/"
prism:ViewModelLocator.AutoWireViewModel="True"
Title="CaseHearing" Height="300" Width="300">
<Grid>
</Grid>
If I want to go to another view, I create new window and use show function in View Model.
ViewB vB_ = new ViewB();
vB_.Show();
when I press show another form button, another duplicate wpf window is open. How can I control it?
I just studied WPF for only 10 days. Is it the correct way of navigating between views?
Best Rgds,
df
The answer is in your question:
I create new window and use show function
So the new window is shown.
You are being confused with the term view. View is not some kind of object in WPF. It's just logical part of MVVM concepts.
Objects that you operate are Windows, controls and pages.
Looks like you want to use WPF pages as different views of your data.
There are plenty of manuals on the net about WPF pages and NavigationService
These are keywords that you need.
BTW, answering the question in the header: The best method to open windows is to wrap opening windows into some generic WindowManager and use
new WindowType(){ DataContext = VM }.Show()

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.

Why is my RibbonWindow not themed correctly?

Working with the ribboncontrolslibrary, when I run my application the title bar looks like W98 application,. How can I make it look pretty?
Edit: It seems that has something to do with the theme used on windows.
any help would be appreciated.
alt text http://img718.imageshack.us/img718/8188/321321.jpg
<r:RibbonWindow x:Class="Produccion_Dampers.main"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:r="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
Title="Window1"
Height="600"
Width="800">
<DockPanel>
<r:Ribbon DockPanel.Dock="Top" Title="my App looks like s***t">
</r:Ribbon>
</DockPanel>
</r:RibbonWindow>
(from my previous comment)
You can draw a custom window frame as described in this MSDN article: http://msdn.microsoft.com/en-us/library/bb688195(VS.85).aspx, which includes information about drawing the window caption with the system theme's font (which might provide clues about accessing other theme information).
If you are running a custom theme on your machine, WPF windows default to the "Classic" theme.
As I understand, your options are then limited because the title bar is non-client to your application -- it is rendered by the OS (why then it can't adopt the custom theme, I don't know).
you can use p/invoke to do some nasty stuff
you can create a borderless window and fake the title bar yourself
you can see if the (rather old) info here does anything good for you : http://www.browsoft.com/tutorials/DefaultTheme.html
(If the last one works, it means my understanding about rendering the title bar is incorrect.)

Categories