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).
Related
This concerns WPF. The problem is that my MediaElement (actually a GIF) doesn't show up at runtime (so I only get an empty screen), even though it shows perfectly in the design mode. Before citing the code I note the following:
The GIF-file in question has been added to the solution.
Its BuildAction property is set to Resource (I've checked).
When I replace the MediaElement by an Image element (and either use the same GIF-file or replace that source-file by a .png file), the image/GIF does display at runtime. Just not when it's used as a MediaElement.
Closing and re-starting Visual Studio doesn't help.
As I said (and just to emphasize, if I may), the GIF image does display in the design mode part of the screen - just not at runtime.
And here's the code:
<Window x:Class="Testing.TestWindow"
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:Testing"
mc:Ignorable="d"
Title="TestWindow" WindowState="Maximized">
<StackPanel>
<MediaElement Source="pack://application:,,,/Images/untitled.gif" Stretch="Fill" Visibility="Visible" />
</StackPanel>
</Window>
Thanks.
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!
On Windows Forms, you have the StartPosition property which allows you to specify the position on the screen your form will be placed when it launches.
Does WPF have an equivalent and if so what is it?
Thanks
I think you are looking for WindowsStartupLocation:
Setting WindowStartupLocation to Manual causes a window to be positioned according to its Left and Top property values. If either the Left or Top properties aren't specified, their values are determined by Windows.
<Window x:Class="WpfAppl.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WindowName"
Height="500" Width="500"
WindowStartupLocation="Manual"
Left="0" Top="0">
</Window>
I want to use viewbox for maintaining my wpf window's aspect ratio. i.e if i put my application on large monitor , it sholud automatically fit to that screen and if run it on my laptop it should adjust to its screen. Please help me out on this . it should be done purely on xaml wpf using view box.
Whats the problem with viewbox ?
Just wrap viewbox around you root views Stretch property to one you like. If you want different scaling you need to write your own implementation of viewbox btw.
Example:
<Window x:Class="stackoverflowviewbox.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Viewbox Stretch="Uniform">
<Grid>
<Label>
Hello world.Hello world.Hello world.Hello world.Hello world.Hello world.
</Label>
</Grid>
</Viewbox>
But it is possible to write xaml so views will look nice on different resolutions without viewbox without any problems.
I would like to have master WPF form with tab control where each tab contains one independent WPF form. Those forms do not depend on each other, so I thought it will be easier to develop each of them separately and then just embed them into master form.
Number of forms is known, so there is no need for dynamic plugin system.
When you use a Frame or NavigationWindow you can have it load different xaml Pages and even html. You can also make it act like a browser with forward and backward navigation. See http://msdn.microsoft.com/en-us/library/ms750478.aspx
You could put a Frame on each tab and have it load a certain Page.
<Window x:Class="PluginApplication.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<DockPanel>
<Frame Name="frame" NavigationUIVisibility="Visible" Source="SomePage.xaml" />
</DockPanel>
</Window>
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
WindowTitle="Page Title"
WindowWidth="500"
WindowHeight="200">
Hello world
</Page>
Make the child forms derive from UserControl, in the master form add a tab control with one of those user controls inside each tab.
I prefer make this with userControl
First create User control
after, include reference of this userControle in another place
anywhere in the frmHome...
<DockPanel>
<Entity:ucContactList/>
</DockPanel>