SOLUTION here
I was asked to emulate a windows forms context menu using a WPF window. I created a window when the user clicked a certain region, but that window got minimized to the task bar instantly. I need it to stay on top of other windows at least until it loses focus or is deactivated. Its window style is none, and it doesn't matter whether its show in taskbar property is true or false. Similar questions exist on SO, but they don't seem to solve anything in my case. Why this odd behavior? Is there a fix for it?
<Window x:Class="InterceptRouteWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" Width="200" ResizeMode="NoResize" SizeToContent="Height" ShowInTaskbar="False" Loaded="Window_Loaded" WindowStyle="None" Height="auto" Deactivated="Window_Deactivated">
<StackPanel Height="auto" Name="stackPanel1" Width="200" Background="WhiteSmoke">
<Separator Height="5" FlowDirection="LeftToRight">
<Separator.Background>
<SolidColorBrush />
</Separator.Background>
</Separator>
</StackPanel>
</Window>
So it's a simple window. The way I invoke it:
IRWindow = gcnew InterceptRouteWindow(routes, fpId, offsetPoint.x, offsetPoint.y);
GetMainFrame()->IRWindow->Show();
This is triggered by a click event inside an older app, a mixture of MFC and WindowsForms.. not my code, I had to obey their design and use WPF where I could.
Related
Image with Problem
This is a WPF application launched with debug of visual studio
I've a window, where show content
<Window x:Class="Test.All"
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:Test"
mc:Ignorable="d"
Title="All" Height="450" Width="800">
<Grid>
</Grid>
and a user control, with the content to show in the window
<UserControl x:Class="Test.ShowContent"
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:local="clr-namespace:Test"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<Button x:Name="btnrand" Content="button" HorizontalAlignment="Left" Margin="300,69,0,0" VerticalAlignment="Top" Width="200" RenderTransformOrigin="0.473,0.477" Height="58" Click="btnrand_Click"/>
<Label x:Name="showblasph" Content="" HorizontalAlignment="Left" Margin="60,169,0,0" VerticalAlignment="Top" Height="163" Width="664" FontSize="24"/>
</Grid>
</UserControl>
With a WinForms application, I did not have that problem, but with wpf yes, any ideas?
The problem is the arrows at the top
You are accidentially using a NavigationWindow instead of a Window. A navigation window has built-in browser-like controls. These controls are not shown in the Visual Studio designer, but at runtime. The black bar at the top are the XAML debugging tools, that you can enable or disable in debug mode.
A navigation window is used automatically, if you specify a UserControl resource as StartupUri. What type of window is used or created depending on the startup URI is documented here.
Types that display a NavigationWindow when set as StartupUri resource:
NavigationWindow
Page
UserControl
FlowDocument
PageFunction<T>
Therefore, you have to set a Window as StartupUri and set its Content to your UserControl.
I just started working with WPF and want to create a simple app.
However, when I place buttons at the bottom of the window and launch the app - they get cut off
Has anyone encountered this problem?
Designer preview shows this
But then when launching the app button gets cut off
XAML code is as follows:
<Window x:Class="DXF2SVG.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:DXF2SVG"
mc:Ignorable="d"
ResizeMode="NoResize"
Title="MainWindow" Height="400" Width="400">
<Canvas Width="400" Height="400">
<Button x:Name="btn_LoadDXFFile" Content="Load .dxf File" Width="100" Height="40" Canvas.Top="334" Canvas.Left="150" />
</Canvas>
</Window>
Thanks in advance!
Everyone who said canvas is evil is right
#NawedNabiZada 's answer about grid and vertical and horizontal alignment did the trick
thanks everyone!
I am using syncfusion: menuItemAdv control for showing a hierarchical menu items for an applications.
OnMouseOver or OnMouseClicked(ExpandMode Property)it shows the sub items on mouse hover a menu items. But It doesn't disappear that list on mouse leave. However, If I click anywhere else on the windows(lost focus probably),then it cleans the sub menu item.
So, Instead of clearing the sub menu items on lost focus. I want to do that on mouse leave as user might open any other application without causing lost focus event and might get confused. So, I want to clear the item list on mouse leave.
I know, I can write a behavior and can hook it's on mouse leave event but I don't know how to clean that list. As there is no method exposed from this library. tempering with item source might screw something.
Any help is appreciated.
xaml is as 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"
xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Window.DataContext>
<local:MainWindowVM></local:MainWindowVM>
</Window.DataContext>
<Grid>
<syncfusion:MenuAdv Width="300" Height="40" ItemsSource="{Binding League}" ExpandMode="ExpandOnMouseOver">
<syncfusion:MenuAdv.ItemTemplate >
<HierarchicalDataTemplate DataType="local:MenuList" ItemsSource="{Binding Teams}" >
<StackPanel Orientation="Vertical" VerticalAlignment="Top" >
<Label Content="{Binding Name}" Height="Auto" FontFamily="Arial" FontSize="12" VerticalAlignment="Top" Margin="0,3,0,0" VerticalContentAlignment="Center"/>
</StackPanel>
</HierarchicalDataTemplate>
</syncfusion:MenuAdv.ItemTemplate>
</syncfusion:MenuAdv>
</Grid>
</Window>
We have checked the reported behavior and considered this as bug. The fix for this bug will be included in our volume 3 SP2 release which is scheduled to be rolled out by end of September.
Regards,
Durga S.
I have a following problem:
I want to load a next screen. And while next screen is loading I want to show loading animation to user.
Its could not be done on another thread than GUI thread.
And I need to run animation at the same time. Also in a gui thread..
The window with animation looks like this :
<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"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
x:Name="Window"
Title="Loading"
Width="640" Height="480" Background="{x:Null}" WindowStyle="None" AllowsTransparency="True" VerticalAlignment="Bottom" WindowStartupLocation="CenterScreen" WindowState="Maximized">
<Grid x:Name="LayoutRoot" Background="#4C000000">
<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Width="277" Height="277">
<MediaElement x:Name="Loading" MediaEnded="Loading_MediaEnded" UnloadedBehavior="Manual"
Source="Images/Loading.gif" LoadedBehavior="Play" Stretch="None" Clip="M0.5,19.5 C0.5,9.0065898 9.0065898,0.5 19.5,0.5 L257.5,0.5 C267.99341,0.5 276.5,9.0065898 276.5,19.5 L276.5,257.5 C276.5,267.99341 267.99341,276.5 257.5,276.5 L19.5,276.5 C9.0065898,276.5 0.5,267.99341 0.5,257.5 z"/>
</Grid>
</Grid>
I create an instance of this class and call Show fuction
LoadingAnim loadingAnimation = new LoadingAnim();
loadingAnimation.Owner = this;
loadingAnimation.Show();
and after that I want to start loading the next screen.
The problem is that animation shows up only after 6 the screen loaded
I think that The problem is I run both of them on the gui thread.
Anyone have an idea what should I do in this case ?
I am having a C# WPF application that runs in full screen. When I place a button in the top right of the canvas and run the application the button doesn't appear. What i figured it out is that the canvas is larger than the screen although I made it the same width and height as the screen resolutions.
PS: The application is working fine on another computer and the canvas size is correct but when I run it on my laptop or PC the same problem appears.
<Window x:Name="Mywindow" x:Class="Graduation_Project.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" SizeToContent="WidthAndHeight" Height="768" Width="1366" WindowStyle="None"
ResizeMode="NoResize" WindowStartupLocation="CenterScreen"
WindowState="Maximized" Topmost="True" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Canvas Name="workspace">
<Label x:Name="Print" Content="Label" Canvas.Left="57" Canvas.Top="719" Width="74"/>
</Canvas>
</Window>
Remove the Height="768" and Width="1366" properties from the Window.