I am building a WPF library that connects windows.
In the example the windows have the following properties:
<Window ...
Height="150"
Width="200"
WindowStyle="None"
ResizeMode="CanResize"
Background="#222222"
AllowsTransparency="False">
<WindowChrome.WindowChrome>
<WindowChrome CaptionHeight="1"
CornerRadius="0"/>
</WindowChrome.WindowChrome>
I use Chrome window because I need to remove the title and be able to resize.
Everything is working well except there are noticeable gaps between windows, although I want to connect them exactly next to each other.
Example layout with 2x magnifier:
https://prnt.sc/26if2vs
What does it cause, can I handle it inside the app, or it caused by the Windows system?
Related
I have a WPF application that is too onerous to rewrite wholesale in UWP. Some of the UWP controls would utilize SwapChainPanel and thus have C++/WinRT to manage DirectX. To determine the feasibility of implementing portions of the application in UWP and including them in WPF, I made a minimal sample app following Microsoft documentation that attempts to compose UWP controls in a WPF application targeting .NET Core 3.1.
<Window x:Class="WpfAppCore3._1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:xh="clr-namespace:Microsoft.Toolkit.Wpf.UI.XamlHost;assembly=Microsoft.Toolkit.Wpf.UI.XamlHost"
Title="WPF App"
Height="500"
Width="800">
<StackPanel>
<xh:WindowsXamlHost InitialTypeName="UwpLib.ManagedGrid"
Height="225" />
<xh:WindowsXamlHost InitialTypeName="UwpLibNative.NativeGrid"
Height="225" />
</StackPanel>
</Window>
This works great for a managed control like UwpLib.ManagedGrid but UwpLibNative.NativeGrid does not load:
The debugger shows an exception:
System.BadImageFormatException: 'Bad IL format.'
That exception indicated to me a build configuration issue, but I think the application is set up correctly in that regard. Is this just not possible with XAML Islands today or have I made some configuration mistake in the sample app?
Update 1:
I discovered the "Windows Desktop Compatible" option and made sure that was set to "Yes". No change.
I have a .exe of a WPF program which is crashing on a PC that is not the one where the .exe was developed, but it does have a copy of Visual Studio installed on it anyway.
When it crashes and I choose to debug it it invokes the local copy of Visual Studio which informs me that the crash happened at a particular line in "mainwindow.xaml" (N.B. not "MainWindow.xaml"). If I right-click in Windows Explorer on the MainWindow.xaml file (because I don't see the lowercase one) the only "open with" option it gives me is something called Windows Presentation Foundation Host (not, for some reason Visual Studio).
If I take that option it brings up my default Firefox browser which asks what I want to do with it, defaulting to opening it in Firefox, which gives me another Firefox browser which asks what I want to do with it, which gives me another Firefox browser, etc, forever.
So what is the Windows Presentation Foundation Host ? And also is there any significance to the fact that the error referred to "mainwindow.xaml" and not "MainWindow.xaml", the latter being a file I actually have in my project?
This is the MainWindow.xaml file . . .
<Window x:Class="MyAB4D_3DLines.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:cameras="clr-namespace:Ab3d.Cameras;assembly=Ab3d.PowerToys"
xmlns:ab3d="clr-namespace:Ab3d.Controls;assembly=Ab3d.PowerToys"
xmlns:visuals="clr-namespace:Ab3d.Visuals;assembly=Ab3d.PowerToys"
xmlns:dxControls="clr-namespace:Ab3d.DirectX.Controls;assembly=Ab3d.DXEngine.Wpf"
xmlns:dxModels="clr-namespace:Ab3d.DirectX.Models;assembly=Ab3d.DXEngine.Wpf"
Title="MainWindow" Height="350" Width="525">
<Grid Background="Black">
<Border Name="ViewportBorder" Grid.Column="0" Background="Black" >
<dxControls:DXViewportView Name="MainViewportView" PresentationType="DirectXImage">
<Viewport3D Name="MainViewport">
</Viewport3D>
</dxControls:DXViewportView>
</Border>
</Grid>
</Window>
The COM object was not created. The following is XAML code:
Title="Window1" Height="373" Width="701" Loaded="Window_Loaded">
Draw Contour
<Window.Resources>
<!--<BitmapImage x:Key="MyImageSource" UriSource="c:/cs3/TextActiveX/TestActiveX/Image.bmp"/>-->
<Image x:Key="MyImageSource" Source="C:\CS3\TestActiveX\TestActiveX\Image.bmp"/>
</Window.Resources>
On load event I check:
if (!this.imageView.Created)
and it appears that control was not created (this.ocx is null).
I understand that something wrong with registration. I tried re-register - does not work. I tried run as admin and even disable UAC and restart Vista - does not work. But if I run MFC test application or HTML script it works just fine.
Sorry text was too long and it was cut. I am using WindowsFormHost to host ATL based ActiveX control. I defined both inside XAML code.
Good day all
I have the following question:
I would like to use Chart from Windows Forms due to the fact that it allows to build much more types of graphical visualisation that one from WPF Toolkit does.
So, I am adding Chart control for Windows Forms as a child element into the WindowsFormsHost. But, when I run the application I and all my clients see only white area. Though, any other Windows Forms Control works great in Windows Forms Host.
What is wrong with the Chart control?
Here is the XAML code
<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:wfi="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
xmlns:CHR="clr-namespace:System.Windows.Forms.DataVisualization.Charting;assembly=System.Windows.Forms.DataVisualization"
Title="Window1" Height="300" Width="300">
<Grid>
<wfi:WindowsFormsHost x:Name="mainFGrid" >
<CHR:Chart x:Name="mainChart" />
</wfi:WindowsFormsHost>
</Grid>
</Window>
Kind regards,
Anatoliy Sova
I found kind of Workaround, basically create the chart at runtime
http://support2.dundas.com/Default.aspx?article=1331
Thanks
Shaik
As a follow up to my previous question, I am wondering how to use transparent windows correctly. If I have set my window to use transparency, the UI will occasionally appear to stop responding. What is actually happening is that the UI simply is not updating as it should. Animations do not occur, pages do not appear to navigate; however, if you watch the debugger clicking on buttons, links, etc.. do actually work. Minimizing and restoring the window "catches up" the UI again and the user can continue working until the behavior comes back.
If I remove the transparent borders, the behavior does not occur. Am I doing something wrong or is there some other setting, code, etc... that I need to implement to work with transparent borders properly?
Here is my window declaration for the code that fails.
<Window x:Class="MyProject.MainContainer"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WPF APplication" Height="600" Width="800"
xmlns:egc="ControlLibrary" Background="{x:Null}"
BorderThickness="0"
AllowsTransparency="True"
MinHeight="300" MinWidth="400" WindowStyle="None" >
And the code that does not exhibit the behavior
<Window x:Class="MyProject.MainContainer"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WPF Application" Height="600" Width="800"
xmlns:egc="ControlLibrary" Background="{x:Null}"
BorderThickness="0"
AllowsTransparency="False"
MinHeight="300" MinWidth="400" WindowStyle="None" >
Are you using .NET 3.0, or .NET 3.5 on Windows XP SP2? If so, this is a known problem with the transparent window API that has been fixed in .NET 3.5 and SP3 of XP (and I think SP1 of Vista). Basically when you set the AllowsTransparency to True, the WPF pipeline has to render in software only mode. This will cause a significant degradation in performance on most systems.
Unfortunately, the only thing you can do to fix this is to upgrade to .NET 3.0 SP1 (included in .NET 3.5), and install the appropriate service pack for Windows. Note that the transparent windows are still slower, but not nearly as bad. You can find a more in-depth discussion here.
I think that I've finally found a workaround. From everything I've read this problem should not be occurring with XP SP3 & .NET 3.5 SP1, but it is.
The example from this blog post shows how to use the Win32 API functions to create an irregular shaped window, which is what I"m doing. After reworking my main window to use these techniques, things seem to be working as expected and the behavior has not returned.
It is also of note that the reason the author recommends this method is due to performance issues with WPF and transparent windows. While I believe it may be better in .NET 3.5 SP1 that it was, this was not that hard to implement and should perform better.
I am running on Windows XP Pro SP3 and using .NET 3.5 SP1. I have also verified that the project is targeting version 3.5 of the framework.