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
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'm try to change my View Model for my Application. Use MVVM and Caliburn.Micro. But when I try open my project in Expression Blend for Visual Studio 2012 I get an error about my Caliburn.Micro dll. I don't see my view window in Expression Blend IDE and have many errors. How make friendly Expression Blend and Caliburn.Micro WPF.
there are directions on www.caliburnmicro.com about setting up design time support since you don't have it configuration at present. It also appears that you a reference issue Message.Attach doesn't appear to be recognized. Doesn't matter if you are using Window, Page, UserControl fyi
<Window
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:CaliburnDesignTimeData.ViewModels"
xmlns:cal="clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro.Platform"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=vm:MainPageViewModel, IsDesignTimeCreatable=True}"
cal:Bind.AtDesignTime="True">
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 have been tasked with utilizing stylecop on .xaml files. Does anyone have a good place to start looking for the best way to accomplish this task. I have drifted around the internet and have yet to find a good solution. Our development environment is VS 2010 WPF application.
Thank you for your help.
StyleCop is a source analysis tool to increase the readability of it. Visual Studio itself would be a good place to start. When you start writing xaml using VS it automatically indents code.
Here is an example
<Window x:Class="WpfApplication3.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">
<Grid>
<Button Content="Hi" />
</Grid>
</Window>
This is what is expected (I think)
<Window x:Class="WpfApplication3.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">
<Grid>
<Button Content="Hi" />
</Grid>
</Window>
As per http://archive.msdn.microsoft.com/sourceanalysis, StyleCop only analyzes C# source code - XAML is a completely different language. If your boss or manager tasked you with using StyleCop on the .xaml files - what they probably meant (and you should double check with them rather than take my word for it), is to analyse the associated xaml.cs files. Every xaml file is a partial class - one part of the class is the XAML (which gets translated to an automatic xaml.designer.cs file which you cannot and should not mess with) - and the other part of the class (often called the codebehind) is the .xaml.cs. This document is one you can use StyleCop on, although some of it's rules may be confused by the fact that it's being run on only one half of a partial class.
That's the best you can hope to accomplish.
The Microsoft Xaml Toolkit has Fxcop integration you might find useful.
blog posting: http://blogs.msdn.com/b/wpf/archive/2010/07/28/microsoft-xaml-toolkit-ctp-july-2010-fxcop-integration.aspx
downloads: http://archive.msdn.microsoft.com/XAML
What is the best way to stop a user from resizing the top-level window of an application written in WPF?
You will want to use the ResizeMode.NoResize on the window.
<Window x:Class="WpfApplication5.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
ResizeMode="NoResize">
</Window>
A WPF quirk to note is that if ResizeMode="NoResize" and WindowStyle="None" you will lose the chrome around the entirely in Vista Aero.