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.
Related
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?
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.
Immediately after adding a brand new, untouched WPF window to my IronPython 2.7 project in VS2013 (with Python Tools for VS 2.0.11016), it tells me "Invalid Markup" in the design window, and the error list shows:
Window is not supported in a Windows Presentation Foundation (WPF) project.
Grid is not supported in a Windows Presentation Foundation (WPF) project.
The XAML window has this innocuous looking code in it:
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Grid>
</Grid>
</Window>
Does Python tools for VS not really support form creation? Did I forget to configure something?
The project was started as an "IronPython Windows Forms Application" rather than an "IronPython WPF Application" so it was missing the relevant references:
PresentationCore
PresentationFramework
WindowsBase
Adding them makes WPF forms functional, or just recreating the project.
If all of those references appear to be in the project, removing/readding some might help. Another user reported he had to do so for 'PresentationFramework'; perhaps there's a couple that have the same name?
For my current project, I am required to display a PDF, and then draw on top of it. I am using Adobe Reader as a PDF viewer, as this can be hosted in a Windows Forms control which can in turn be hosted in a WPF application. However, I cannot draw over this control.
There seem to be a couple of approaches to solving this problem out there, but for the life of me I cannot seem to find a good example of a generic solution that would fit into my existing code. The most common solution I can see are Adorner/Layer/Decorators, but I can't find a way to get them into my XAML in a way that won't break the application.
My current XAML is as follows:
<Window x:Class="ThisProject.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ThisProject"
Title="MainWindow" Height="768" Width="1366"
WindowState="Maximized" WindowStyle="None" KeyDown="WindowKeyDown"
Loaded="WindowLoaded">
<Grid Name="PDFGrid">
<local:PDFViewerHost x:Name="PdfViewer"/>
</Grid>
</Window>
What I will need to go on top of the PDF viewer is a bunch of shapes, defined at runtime. Any suggestions as to a method that will allow me to stick those shapes on top of it would be greatly appreciated.
Thanks!
I'm developing a new desktop application that will have several views such as a dashboard, event viewer, chart viewer to name a few. Essentially the user will switch between one of these view which will cover the whole screen and not just a part of it.
I'm currently stuck on whether I should be creating a new Window, Page or UserControl for each dashboard, event viewer, chart viewer etc.
I have done some reading and understand that Pages were built for navigation which in turn lets me keep a history of the navigation so I can go back/forward. However I don't think I need that functionality for my desktop application.
So can I use either a UserControl or a Window? Or should there only be one Window per application?
Thanks
A Window has things like Title bar (including min/max/close buttons, etc) and can be used to host XAML elements, such as User Controls.
You are certainly not restricted to using one Window per Application, but some applications would choose that pattern (one window, hosting a variety of UserControls).
When you create a new WPF Application, by default your app is configured (in App.xaml) like this:
<Application x:Class="WpfApplication1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>
The StartupUri property tells the app which Window to open first (you can configure this if you wish)
If you would like to logically separate your Window into pieces and do not want too much XAML in one file, you could do something like this:
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfApplication1"
Title="Window1" Height="300" Width="300">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition />
</Grid.RowDefinitions>
<local:HeaderUserControl Grid.Row="0" />
<local:MainSectionUserControl Grid.Row="1" />
</Grid>
</Window>
where HeaderUserControl and MainSectionUserControl are UserControls encapsulating the aspects of that Window, as needed.
If you want to show another Window, you can, in code, call Show or ShowDialog on an instance of the new Window you want to show...
Also - yes, a Page is part of a WPF Browser application, designed to be viewed in Internet Explorer.
A page is something you would use in a browser, not for a standalone application.
The Window class represents a top-level object, that is, it is not meant to be contained in another control. All the windows you see while using the Windows OS (if they were WPF application) would be created by deriving from the Window class, and you would use the Window class to create your own windows.
The UserControl class lets you create new custom controls, in case a standard control does not already exist for what you need. A UserControl can be contained inside of a window or another control, but a Window is not contained inside anything (this is the big difference!)