using WPF (beginner) :-)
i keep getting the error
"ApplicationCommans is not supported in a Windows Presentation Foundation (WPF) project"
i just begin my project ..
Solution Platform : AnyCPU
<Window x:Class="Wpf_CreatingARichTextEditor.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:Wpf_CreatingARichTextEditor"
mc:Ignorable="d"
Title="MainWindow" Height="300" Width="400">
<Window.CommandBindings>
<CommandBinding Command="ApplicationCommans.Open"
Executed="CommandBinding_Executed" />
</Window.CommandBindings>
<Grid>
</Grid>
</Window>
thanks
It's not ApplicationCommans..it's ApplicationCommands.Open. Just change the name of the command it should fix the issue.
Hope this helps.
For me, I got this issue when copying from MSDN and pasting into the XAML. There was an invisible zero-width joiner character between Application and Commands that I had to delete (presumably to help with word-wrapping)
Related
I'm trying to use a winform control in WPF(I've not found good alternative).
The control is the be.hexbox from sourceforge: https://sourceforge.net/projects/hexbox/files/hexbox/
So I Start a new solution VB.net WPF and add WindowsFormsIntegration.dll reference.
I also add reference to the control dll.
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:wf="clr-namespace:Be.Windows.Forms;assembly=Be.Windows.Forms.HexBox"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp2"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<WindowsFormsHost Name="TEST1">
<wf:HexBox x:Name="HX" />
</WindowsFormsHost>
</Grid>
</Window>
but I get this error:
Error XLS0502 The 'WindowsFormsHost' type does not support direct content.
Any advice?
Indeed, you can't set a direct Content in a WindowsFormsHost element, you need to set the Child property instead.
Try this:
<WindowsFormsHost Name="TEST1">
<WindowsFormsHost.Child>
<wf:HexBox x:Name="HX" />
</WindowsFormsHost.Child>
</WindowsFormsHost>
The project must have a reference to both:
WindowsFormsIntegration
System.Window.Forms
In my experience you do not need to specify <WindowsFormsHost.Child> in XAML. This may be dependent on the version. I am currently using .NET Framework 4.8.
I'm having problem trying to include a winform user control in WPF. My control gets cropped whatever I try to do.
The control keeps autosizing itself even when I have not set the option.
Here's what it looks like
Here's the XAML
<Window x:Name="mainForm" x:Class="RFID.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:RFID"
mc:Ignorable="d"
xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
xmlns:sp="clr-namespace:gei1076_tools;assembly=gei1076_tools"
Title="MainWindow" Height="350" Width="755.682">
<Grid>
<WindowsFormsHost>
<sp:SerialPortConfigurator x:Name="spcConfigurator" ></sp:SerialPortConfigurator>
</WindowsFormsHost>
</Grid>
</Window>
What am I missing?
Thanks
I'm new in WPF (.NET 4.0, VS2010) and try to include a property grid. My XAML Markup looks like the following:
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:WpfToolkit="clr-namespace:Xceed.Wpf.Toolkit.PropertyGrid;assembly=WPFToolkit.Extended"
Title="MainWindow" Height="350" Width="525">
<Grid>
<WpfToolkit:PropertyGrid Name="Grid" />
</Grid>
</Window>
Now I get the error that the assembly 'WPFToolkit.Extended' was not found. I have included the reference to the dll Xceed.Wpf.Toolkit.dll in my application.
Why does it not work? Have I to include more references or what can be the mistake?
Thanks for any Response.
I could solve the problem. My fault was that I had not unblocked the zip file containing the dll. After this I have to change the source for the namespace in the Markup to an uri. Below the final markup:
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:WpfToolkit="http://schemas.xceed.com/wpf/xaml/toolkit"
Title="MainWindow" Height="350" Width="525">
<Grid>
<WpfToolkit:PropertyGrid Name="Grid" />
</Grid>
</Window>
Check your project properties. Under application, what is selected under target framework? By default with a new project, '.Net Framework 4 Client Profile' is selected. If the extended library uses parts of .net that beyond the client profile, you will need to select '.Net Framekwork 4' instead to use the extended functionality.
I created a new wpf application, with the default MainWindow.xaml,
and I created a new page: Page1.xaml with a button in it.
I want to embed the page in the window, so I tried:
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:WpfApplication1="clr-namespace:WpfApplication1" Title="MainWindow" Height="350" Width="525">
<Grid>
<WpfApplication1:Page1></WpfApplication1:Page1>
</Grid>
</Window>
Then I got a exception.
I searched here, and got another solution, using
so I tried 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:WpfApplication1="clr-namespace:WpfApplication1" Title="MainWindow" Height="350" Width="525">
<Grid>
<Frame Source="Page1.xaml"/>
</Grid>
</Window>
it worked.
But
what if the Page1.xaml is not in current project but in a dll file?
The general template to get resources from another assembly is : Source="pack://application:,,,/YourAssembly;component/Subfolder/YourResourceFile.xaml"
Take a look a this on MSDN
When I try to run a simple, basic Silverlight application, I got the following error:
Can't find the TestPage.html, Make
sure the path or internet address is
correct.
Here is my XAML code:
<UserControl x:Class="HelloWorld.MainPage"
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"
mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">
<Grid x:Name="LayoutRoot" Background="White">
<TextBlock Text="Hello, World!" />
</Grid>
</UserControl>
What could be the reason for this? Any help would be greatly appreciated.
Thanks.
This sounds like an issue with your project setup. Make sure your ASP.NET project is correctly set with your Silverlight project as a contained Silverlight app. Also you will want to check that in the Project Properties the Startup Item is set to an existing page. It may not be TestPage.html.