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.
Related
I am developing a WPF app using MVVMCross. I started with the TipCalc Tutorial where we have the following MainWindow.xaml:
<views:MvxWindow x:Class="UI.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:UI"
xmlns:views="clr-namespace:MvvmCross.Platforms.Wpf.Views;assembly=MvvmCross.Platforms.Wpf"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
</Grid>
</views:MvxWindow>
My goal is to set the title from the core project. Therefore, I need a view model for the MainWindow. It seems, that this is implicitly defined in MVVMCross. Is there any chance to set the application title for a WPF application in MVVMCross via data binding?
Yes, you can add property Title on the current ViewModel then bind it later
Title="{Binding Title}"
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 have a solution whose structure is similar to:
I am trying to import the TypeConverters namespace into MainWindow's static resources so that I can use MyTypeConverter in a binding.
After doing some reading I know that I have to add the assembly if importing a namespace that is not within the same assembly.
<Window x:Class="WpfApp1.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:converters="clr-namespace:TypeConverters;assembly=ClassLibrary1"
xmlns:local="clr-namespace:WpfApp1"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Window.Resources>
<converters:MyTypeConverter x:Key="MyConverter"/>
</Window.Resources>
<Grid>
</Grid>
</Window>
Visual Studio tells me that "The name MyTypeConverter does not exist in the namespace clr-namespace:TypeConverters;assembly=ClassLibrary1"
Not quite sure what to do here. Am I referencing this correctly? Do I need to use different syntax since it exists in the same solution?
Thanks
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)
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