Metro template for WPF app. I want a Window which dont have any Window Command like minimize maximize and close. In normal WPf it can be done by WindowsStyle but how i can remove them in this template. And i also want to make the Window to be TopMost="True" and WindowState="Maximized". So all this settings are possible in this template ? Please advice ?
No need to thange templates, just set some properties.
MetroWindow has properties:
<controls:MetroWindow ...
Topmost="True"
WindowState="Maximized"
ShowTitleBar="False" // Hide colored tile bar, title header and icon
ShowCloseButton="False"
ShowMaxRestoreButton="False"
ShowMinButton="False"
ShowWindowCommandsOnTop="False" // No window commands on top of flyouts
which will remove title bar (icon+color), and you can remove buttons too.
Related
To edit non client area, I need to create my own title bar in my WPF app setting WindowStyle to none and non resizable. I have created my own caption button but it don't get the feel of Windows 11. When we hover mouse over middle button we can see a window snap option as seen in this image
Is there anyway to achieve this, I mean there should be, I even tried many nuget packages having custom Window, but I didn't got what I wanted.
All I want is to get a Window with System's default Window behavior but can have a Sliding panel from left which is even over title bar, somewhat like this but I dont want to make title bar myself I want systems default.
Even if its custom made I want it perfectly same as System's Default Window
Its already in many Windows apps :- Clock ,Mail, Even Word .
In each of this apps left panel is over title bar and even preserving the system's default window behavior, Please Please Please tell me I have been looking for it from 2 months.
Nuget Package I tried : https://github.com/Kinnara/ModernWpf
code I tried:
<Window '''''default code ''''
''''''''''''''''''''''
''''''''''''''''''''''
''''''''''''''''''''''
WindowStyle="None"
ResizeMode="NoResize">
<!--This created blank window with no title bar-->
<Grid>
<!--creating title bar-->
<Grid ''''' code so grid appear as title bar on top
and we can drag too>
<!--caption buttons-->
<button ''''button with '-' and style as
windows caption button and minizimes window
when clicked'''''''''''/>
<button ''''button with 'square symbol' and style as
windows caption button and maximize or restore window
when clicked'''''''''''/>
<button ''''button with 'close symbol' and style as
windows caption button and close window
when clicked'''''''''''/>
</Grid>
<!---
rest of the code
""""""""""""""""""
"""""""""""""""
""""""""""""""""--->
</Grid>
<Window/>
When I join a meeting on skype or teams I need to share the content of the application main window (without any other thing on the screen), but it's not showing in the window share menu, I can only stream it with the whole desktop.
see image here
But, when I open Login window it appears in the window share menu while the main window still do not appear ! As in the image below.
Login window appears in the menu
Does anyone have any idea what would prevent the window from appearing in the window share menu ?
I had the same problem and I figured out that the window needs a Title so it is selectable in Teams for sharing.
Once I added the Title to my main window everything works.
It can be done in the code:
mainWindow.Title = "test";
or in XAML:
<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"
Height="900" Width="1200" MinWidth="900"
x:Name="mainWindow"
Title="{x:Static p:Resource.MainView_Header}">
...
</Window>
In my WPF application, Need to show a Non-modal window.
I am using MVVM Light framework.
People are suggesting different libraries to do so but is there any suitable control to do that using MVVM Light or using WPF native library?
Need to keep that non-modal window always on top.
Thanks.
To create a non-modal window you won't have to use a framework. The WPF library has enough possibilities to create it.
The quickest solution is to create a new Xaml Window and within the properties of the Xaml Window code, you van specify the TopMost priority, and set it to true.
<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="NonModalWindow" Height="300" Width="300" TopMost="True">
<Grid>
<!---- Some element defined in your window ---->
</Grid>
</Window>
Once you have created this window it is only a matter of calling it.
new NonModalWindow().Show();
And if you do want to make it into a Modal window you can use to following code.
new NonModalWindow().ShowDialog(); // wooah a contradiction in the code
How do I change the default page header in a Windows 8 XAML application? The question is simple, just I am still learning XAML.
<Page.DataContext>
<local:MainPageViewModel/>
</Page.DataContext>
<!-- PageAdornerControl displays the back button and a page title -->
<Layout:PageAdornerControl
Background="{StaticResource ApplicationPageBackgroundThemeBrush}"
Header="{Binding Header}">
I see Header as the text. My first thought was to change {Binding Header} to {Binding }, however a mouse over on Header shows that as some valid whatever. Also, I would like to use the Visual Studio 2012 properties window to change the text.
There might be other ways, and I am still less than green with XAML, but here is one way using Nate's pageAdornerControl method.
Place the cursor on the Layout:PageAdornerControl in the XAML code area.
Go to the properties window, which should show the type as PageAdornerControl.
Scroll down to header
From the dropdown list, select Go to Source
You will now see another section of code highlighted.
Go to the properties window and the Header attribute will be the actual header text, which you can edit.
I am trying to migrate an existing Winforms project into WPF. However: there are some user controls I need to leave as WinForm controls.
I have added a WinForms UserControl into a WPF Window. It consists of a RichTextBox and some buttons and labels. This is subclassed into various further user controls.
When I embed the UserControl into a WPF window it renders - but none of the buttons appear to do anything. When underlying processes update e.g. the RichTextBox it does not display the content. Yet when I inspect the textbox in debug I can see the content (though I have to click on 'base' to see this.)
[ One difference I have spotted - though it may not be relevant - is that when this control is on a WPF and non-working Visual Studio shows the object as 'sealed' but when in the original Winforms project when it is fully working it does not show as sealed. ]
I have added code to change the text in the labels - and they also firmly refuse to update: yet again I can see the text if I examine the label in debug mode.
This stack overflow question may address the same issue:
WindowsFormsHost Winform pdfviewer control problem
but the answer didn't make a lot of sense to me:
It mentioned replacing
new Window { Content = CreateContent(), Title = title }.Show();
But this is not a piece of code I recognise: I am using a xaml file with code behind and it's called up using
System.Windows.Application app = new System.Windows.Application();
app.Run(new FormWPFApp());
(where FormWPFApp is my name for the WPF window)
Here is the xaml header:-
<Window x:Class="ZedApp.FormWPFApp"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Printers="clr-namespace:ZedApp.UserControls.Printers"
xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
Title="Conversion version" Height="661" Width="1559" Loaded="Window_Loaded">
Here is the xaml I use for the two UserControls (they both inherit from the same base class) :-
<WindowsFormsHost Height="430" HorizontalAlignment="Left" Margin="192,32,0,0" Name="windowsFormsHostTicketPrinter" VerticalAlignment="Top" Width="324" Grid.Row="1" Grid.Column="1">
<Printers:TicketPrinter x:Name="ticketPrinter">
</Printers:TicketPrinter>
</WindowsFormsHost>
<WindowsFormsHost Height="430" HorizontalAlignment="Left" Margin="522,32,0,0" Name="windowsFormsHostJournalPrinter" VerticalAlignment="Top" Width="324" Grid.Row="1" Grid.Column="1">
<Printers:JournalPrinter x:Name="journalPrinter">
</Printers:JournalPrinter>
</WindowsFormsHost>
[Another thing I have noticed is a method that clears the Rich Text Box on one of the windows starts kicking out errors of the following type if run under WindowsFormsHost in WPF -
"Invoke or BeginInvoke cannot be called on a control until the window handle has been created."
private void ClearRichTextBox(RichTextBox rtbToClear)
{
if (rtbToClear.IsHandleCreated)
{
if (rtbToClear.InvokeRequired)
{
this.Invoke(new Action<RichTextBox>(ClearRichTextBox), new object[] {rtbToClear});
return;
}
rtbToClear.Clear();
}
}
]
What is the likely cause of this behaviour and what do I need to do to get the elements within the User Control working?
Proper input interop with WinForms requires some cooperation between the host and the WPF input system. The topic Message Loops Between Win32 and WPF in the SDK explains this well. In your setup, the easiest way to make this happen is to use code like this:
Window w = new Window1();
System.Windows.Forms.Integration.ElementHost.EnableModelessKeyboardInterop(w);
w.Show();
ElementHost.EnableModelessKeyboardInterop() essentially registers an input hook with the WinForms Application object (which normally runs the message loop) and calls ComponentDispatcher.RaiseThreadMessage().