WPF Page Title Bar Hide - c#

I know how to hide the title bar in windows: WindowStyle="none". But how can i achieve that with Pages?
I have a code like this:
<Page x:Class="SomeNamePage1"
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"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:local="SomeName"
mc:Ignorable="d"
d:DesignHeight="700" d:DesignWidth="700" WindowHeight="700" WindowWidth="700"
Title="Page1" Background="#FFFFFF">
How can i hide the title bar with the same results as WindowStyle="None"?

I figured out that's not possible. I solved using a Window as holder for the navigation menu and a frame that switches between Pages for the content.
Hope this helps others!

Related

Open previous TabViewItems after page navigation of NavigationView class

I want to save the opened TabViewItems dynamically, so that the user can switch to another page and return to his work, for example.
Problem:
Open previous TabViewItems after page navigation of NavigationView class
If you initialize the TabView's DataSource in the Page ctor, you could set the page's NavigationCacheMode as Required like the following
<Page
x:Class="App19.MainPage"
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:local="using:App19"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
Background="Transparent"
NavigationCacheMode="Required"
mc:Ignorable="d">

Edit Xaml files on debuging Visual studio 2019, WPF

I want to Edit UI XAML files with my program running and see these changes without to stop my program...
When I change these files right now It just o nothing until I close my program and start again.
For exmaple:
this is my xaml code:
<Window x:Class="WpfApp4.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:WpfApp4"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
</Grid>
</Window>
http://prntscr.com/nwiw0o
I see an empty white screen
When I change it (on debug) to
<Window x:Class="WpfApp4.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:WpfApp4"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800" Background="Blue">
<Grid>
</Grid>
</Window>
http://prntscr.com/nwiw7q
Nothing is change
But when I restart my program
It runs this blue screen...
http://prntscr.com/nwiwiw
I think its something about debugging option?
this is my page open list
http://prntscr.com/nwiwtu
You probably don't have "Edit and continue" enabled, because you can just edit xaml and see the result immediately if you do.
From the Debug menu, choose Options.
On the left Debugging should be selected for you and the default will be the first option - General. If that isn't selected, do so.
Scroll the right panel down.
Tick the Enable UI debugging tools for XAML and at least Enable XAML Edit and Continue.
You should then be able to change simple properties in XAML and see your changes reflected immediately in the running UI. It does not work for everything though.
https://devblogs.microsoft.com/visualstudio/ui-development-made-easier-with-xaml-edit-continue/

Navigating between pages in wpf not working

I've done the simplest thing. I open a new window and put a frame in it and I wanted to show in the frame a page.
The window code:
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
Page1 p = new Page1();
navigator.NavigationService.Navigate(p);
}
}
navigator is the frame, in Page1 I have black background color to see the difference. When I run it I still see the window and not the page that should be inside the frame. Why isn't this working?
Window:
Page:
But i get the white one.
The code for page 1:
<Page x:Class="test.Page1"
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="269" d:DesignWidth="292"
Title="Page1">
<Grid Background="Black">
</Grid>
In the cs side i didn't write anything.
You need to set the Content property of the Page to something to be able to actually see it:
<Page x:Class="test.Page1"
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="269" d:DesignWidth="292"
Title="Page1">
<Grid Background="Black">
<TextBlock>PAGE1</TextBlock>
</Grid>
</Page>
An empty black Grid is not visible but if you put a TextBlock in it you should be able to see it.

how to set header for change place of app window

i made a wpf app and set the WindowStyle to None
but
when i cant change the place of app
and
is there any other way to change the size of app without set ResizeMode to CanResizeWithGrip?
<Window x:Class="WpfApplication1.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:WpfApplication1"
mc:Ignorable="d"
Title="MainWindow" Height="358.685" Width="542.37"
ResizeMode="CanResizeWithGrip" WindowStartupLocation="CenterScreen"
WindowStyle="None" AllowsTransparency="True" Background="White">
</Window>
If I understood correctly you want to re size your main window in code.
You can do this anywhere in code by using the following:
App.Current.MainWindow.Width = 500;
App.Current.MainWindow.Height = 500;
where of course you can substitute 500 with whatever size you want.

UserControl content can't be set more than once

having some troubles with UserControl. I cannot get rid of "Content is set more than once error"
From what I've read, the common cause is that .. well, content is set more than once. For example having more than one child or setting content via Content=".." and then specifying another content between the tags.
However, this is UserControl generated by VisualStudio and I made no changes to the xaml.
<UserControl x:Class="TMEGadget.View.Toolbox"
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>
</Grid>
</UserControl>
Got any tips?
P.S: Can anyone tell me why, when I try to type "Hey,\n\nSome text...", the "Hey,\n\n" is deleted?
Edit: Restarting VS fixed the problem , thanks #Bolu

Categories

Resources