How to restyle wpf window like Blu twitter client - wpf

for a long time i am looking for trick to develop a Blu like window where some leaf image is coming out from title bar. how they design such layout.
here is small image of custom title bar
please some one tell me how could i design this type of title bar where something coming out from title bar.

You can achieve this by setting an appropriate background image for the window and setting AllowsTransparency to True:
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" WindowStyle="None" AllowsTransparency="True">
<Window.Background>
<ImageBrush ImageSource="/bg.png"/>
</Window.Background>
Then you have to create your own title bar, because the default one will not be displayed.

Related

hide top panel in wpf main window

I am new to WPF. I create a new project in wpf and in mainwindow.xaml I wrote following
<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"
Title="MainWindow" Height="350" Width="604" WindowStartupLocation="CenterScreen" WindowState="Maximized" IsTabStop="False" Focusable="False">
<StackPanel>
<TextBlock Text = "Welcome to XAML Tutorial with VB.net" Height = "20" Width = "220" Margin = "5"/>
<Button Content = "Ok" Height = "20" Width = "60" Margin = "5"/>
</StackPanel>
when i run the window a panel automatically opens at the top as following
How to hide this? Please help me.
Generally go to the main menu of VS and open the Debug menu. Select Debug | Options. This will open the debugger options dialog. Under the Debugging section select Hot Reload. Then, in the right view, spot the WPF and UWP section and uncheck the Enable in-app toolbar checkbox. Click OK to leave the dialog.
This is a debugging feature, quite useful at times.
To disable it, uncheck the Enable XAML Hot Reload under Tools -> Options.

How to show alignment line between two windows

I have windows inside a dock panel which are resizable.
Is there a way to show an alignment line between controls, while dragging or resizing?
What you need to do is to create a new window wihthout decoration like this:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="640" Height="480"
WindowStyle="None"
AllowsTransparency="True"
ResizeMode="CanResizeWithGrip">
<!-- Content -->
</Window>
Then you calculate the placement of your separator line and draw that line in this window. That is the only way I know to draw stuff "between" windows (regardless of platform, the same is true for any language/toolkit like Qt5, Java Spring etc).

Strange strip at the top of Windows 10 (wpf)

I have this xaml on a project that uses Caliburn micro :
<Window x:Class="Myproject.MainWindowView"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
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:cal="http://www.caliburnproject.org"
mc:Ignorable="d" d:DesignHeight="800" d:DesignWidth="1024" WindowStyle="None" Background="Black" >
</Window>
but when I run the application, I have a white line at the top of window :
How can I remove the line at the top?
I need a window that has no title bar, but should be resizable.
Well for the sake of easy points I suppose, the window chrome is built into the style templates and still inherited when you define WindowStyle="None" but still allow re-sizing to allow a hit spot for the manipulation event to occur. So like described in another answer you can take control of the base template and edit it to your requirements while still retaining the ability for the user to have point to invoke the re-sizing ability but with the frame thickness set to 0.
Hope this helps, cheers!

Remove the window title color for XamRibbonWindow

I have a wpf window using XamRibbonWindow class, from an old code base.
I don't know why its black color will cover the minimize, maximize, and close buttons. I am not sure if this is caused by XamRibbonWindow either.
Those buttons still works, just hidden behind the title color.
Also, if I press maximize button twice, the black color will be gone.
Anyone has similar experience and knows how to fix it?
The mainwindow.xaml is like:
<igRibbon:XamRibbonWindow x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Geomagic.Shared.UI.WPF.IFGuiService"
xmlns:igRibbon="http://infragistics.com/Ribbon"
>
<Window.Resources>
<local:StringData x:Key="Theme" Ref="Theme"/>
</Window.Resources>
<igRibbon:RibbonWindowContentHost x:Name="_contentHost" Background="{DynamicResource ContentHostBackground}">
<igRibbon:RibbonWindowContentHost.Ribbon>
<igRibbon:XamRibbon/>
</igRibbon:RibbonWindowContentHost.Ribbon>
<local:DockManagerWindow x:Name="_dockManager"/>
</igRibbon:RibbonWindowContentHost>

Changing the start up location of a WPF window

I'd like to have a WPF window open in the top right part of the screen.
Right now I can achieve that by opening the window and then moving it (via movewindow in user32.dll). However, this approach means the window opens in it's default location, fully loads, and then moves to the top right.
How could I do I change it so that I could specify the window's initial position and size?
Just set WindowStartupLocation, Height, Width, Left, and Top in xaml:
<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1"
Height="500" Width="500"
WindowStartupLocation="Manual"
Left="0" Top="0">
</Window>
I like to use WindowStartupLocation="CenterOwner" (MSDN docs for it)
The caller needs to specify itself as owner for this to work though, such as:
new MyWindow() { Owner = this }.ShowDialog();
Then just define the window height and width, e.g:
<Window ...
Height="400" Width="600"
WindowStartupLocation="CenterOwner"
>
...
For people who like me wanted to set the position of the window to the current mouse position, you can do it like this:
myWindow.WindowStartupLocation = WindowStartupLocation.Manual;
myWindow.Left = PointToScreen(Mouse.GetPosition(null)).X;
myWindow.Top = PointToScreen(Mouse.GetPosition(null)).Y;
There is a property for Window, called "WindowStartupLocation"
You can find that in properties window. Simply just select Window in constructor, then go to properties list. Search for "Startup" or smth similar and you can find that property. Change it to "CenterScreen" and it will make the deal.
NOTE! Make sure, that you did not select grid instead of window! Otherwise you`ll fail.
Or you just can done it via XAML editing as some guys wrote before.
This is what worked for me (with a different placement on screen):
<Window x:Class="BtnConfig.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:BtnConfig"
mc:Ignorable="d"
Title="MainWindow" Height="142.802" Width="448.089"
Top="288" Left="0">
</Window>
Notice it does not contain:
WindowStartupLocation="Manual"
In my case I want my "Find" tool box to appear top-right corner of the RichTextBox control.
It is done with this code:
// Assumes variable: RichTextBox m_Box, Window m_FindWordDialog
m_FindWordDialog.Show( ); // Let dialog show itself first
// Note: I had to use ActualWidth because m_Box.Width somehow is (NaN) in my case
// Not tested in different DPI.
Point locationFromScreen = m_Box.PointToScreen( new Point(m_Box.ActualWidth, 0) );
m_FindWordDialog.Left = locationFromScreen.X - m_FindWordDialog.Width;
m_FindWordDialog.Top = locationFromScreen.Y;
My search window XAML has following properties.
WindowStartupLocation="Manual" Left="0" Top="0"
It will briefly appear on its initial location and jump a bit, but I can live with it. Actually any value is fine, WindowStartupLocation="CenterOwner" also work, it just jump from center of parent. Or as dirty workaround, you could use manual mode and let it start in faraway position to not let user see jumping.
To make it appear relative on desktop position, acquire the screen workspace location, you can check: How to set the location of WPF window to the bottom right corner of desktop?

Resources