I'm using VS2013 Express. I'm quite new in WPF and MVVM. I've downloaded mvvmlight using NuGet to my project. I'm tryinng to use GalaSoft_MvvmLight_Command:EventToCommand. As far as I know, I have to add reference in xaml by adding namespace:
xmlns:GalaSoft_MvvmLight_Command="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight"
But, unfortunatelly I get error, that says:
The tag 'EventToCommand' does not exist in XML namespace
'clr-namespace:GalaSoft.MvvmLight;assembly=GalaSoft.MvvmLight'.
I've found some information, that I have to include GalaSoft.MvvmLight.WPF45 assembly, but I don't see this dll in packages\MvvmLightLibs.5.0.0.1\lib\ folder. There are many folders, for each .NET version etc, but each of these assemblies names are the same, without WPF45 sufix.What is going on? Where do I find this GalaSoft.MvvmLight.WPF45.dll assembly? Or maybe in version 5 was some changes made in names?
Edit:
Using object browser I found that EventToCommand is in GalaSoft.MvvmLight.Platform assembly in GalaSoft.MvvmLight.Command namespace. So I did
xmlns:GalaSoft_MvvmLight_Command="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Platform"
I can compile project now, but I still get errors in xaml (what is weird):
A value of type 'EventToCommand' cannot be added to a collection or dictionary of type 'TriggerActionCollection'
and
The type 'EventToCommand' from assembly 'GalaSoft.MvvmLight.Platform' is built with an older version of the Blend SDK, and is not supported in a Windows Presentation Framework 4 project.
and xaml editor can't display window properly (invalid markup).
Edit2:
Solution for invalid markup.
After I've changed the namespace to xmlns:cmd="http://www.galasoft.ch/mvvmlight" I also change project's target framework from 4.5 to 3.5. IDE shows an error about there are few NuGet packages that target other framework, so I returned to 4.5 - and it magically works now ;). Thanks all for help.
Here's how its done now in your XAML assuming you've got Version 4.0.0. Beat 1 or higher:
xmlns:cmd="http://www.galasoft.ch/mvvmlight"
I found this at the bottom the release notes here: http://www.mvvmlight.net/installing/changes/
Details
XmlnsDefinitionAttribute for GalaSoft.MvvmLight.Command in Extras assembly
Thanks to the addition of XmlnsDefinitionAttribute, you can simplify the inclusion of the MVVM Light EventToCommand action in XAML. See the before and after below:
Before:
<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.SL4"
xmlns:cmd="http://www.galasoft.ch/mvvmlight"
x:Class="MvvmLight4.MainPage">
After:
<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:cmd="http://www.galasoft.ch/mvvmlight"
x:Class="MvvmLight4.MainPage">
EventToCommand exists in the Extras assembly.
Try:
xmlns:GalaSoft_MvvmLight_Command="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras"
More Information:
To determine the assembly a class falls in, I usually Go To Definition and the assembly is referenced in the region at the top of the [from metadata] code file.
Related
I am using the basic WPFToolkit - I have both DLL's embedded in my EXE. I followed this tutorial:http://www.digitallycreated.net/Blog/61/combining-multiple-assemblies-into-a-single-exe-for-a-wpf-application
Everything is working with the DLL not embedded. When embedded, while I can compile with no error, I get a parsing error pointing at the XAML referencing of the wpftoolkit dll.
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:chartingToolkit="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit" x:Class="Swiftech_Imperium.MainWindow"
both DLL's are set to embedded resources, and both references are set to do not copy.
If I enable copy local for the system.windows.controls.datavisualization.toolkit.dll it works, but then I need the DLL at the root of the exe (I shouldn't need that since it's already embedded in the EXE - and I can't do this for this specific project..)
any idea what's wrong here?
thanks
Just because the .DLL reference is set to Embedded Resource doesn't mean the libraries will get resolved/loaded at runtime. You need to manually do that. I'm not sure if WPFToolKit can successfully do that, but to test it, you will want to to follow the answer found here.
I'm aware this is the same issue as raised in "PageFunction is not supported in a Windows Presentation Foundation (WPF) project" 2012 - however, I'm unsure as to how to apply the workaround mentioned there, and thought it may be more appropriate to raise this as a separate question. Apologies in advance if this is against the site ethos.
To summarise the problem: I have a C# Visual Studio 2010 WPF project that's a couple of years old, which I'm now trying to open in Visual Studio 2012. Although the project still builds and runs fine, I need to edit the XAML markup, and the Design view in VS2012 complains of "Invalid Markup". The exact error it's tripping up on is:
Page Function is not supported in a Windows Presentation Foundation
(WPF) project
The start of the XAML looks like:
<PageFunction
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:MyNamespace"
x:Class="MyProject.WizardPage1"
x:TypeArguments="local:WizardResult"
KeepAlive="True"
WindowTitle="My Project" Height="350" ShowsNavigationUI="False" Width="700" >
As mentioned in the original question, there are reports of this exact issue on this Microsoft page. There is a workaround mentioned involving "ViewBase", but I cannot see how this relates to the PageFunction problem (I'm very new to XAML so I may be missing something simple).
I've tried opening the project in Blend for VS2012 (the new Preview version that supports non-Windows 8 projects), but that gives the same error about PageFunction not being supported. The recent Update 1 for VS2012 hasn't fixed the problem either.
Can anyone advise what I need to change in my XAML or code-behind in order to be able to visually edit this page?
Or should I give up and just re-download VS2010 in order to edit this project?
Based on the workaround, you'll need to create a class which derives from PageFunction<WizardResult>, and then update your XAML to inherit from that class.
Class:
public class WizardResultPageFunction : PageFunction<WizardResult>
{
}
Code-behind:
Either change the class to inherit from your new class, or remove the base-class declaration completely and let the XAML define the base class:
public partial class WizardPage1
// or:
// public partial class WizardPage1 : WizardResultPageFunction
{
...
}
XAML:
Replace the PageFunction with local:WizardResultPageFunction and remove the x:TypeArguments attribute:
<local:WizardResultPageFunction
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:MyNamespace"
x:Class="MyProject.WizardPage1"
KeepAlive="True"
WindowTitle="My Project" Height="350" ShowsNavigationUI="False" Width="700"
>
I am trying to start using Telerik's RadDataFilter.
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
...
<telerik:RadDataFilter Name="radDataFilter"
Source="{Binding FirstEntries}"/>
But I get an error:
The tag 'RadDataFilter' does not exist in XML namespace 'http://schemas.telerik.com/2008/xaml/presentation'. Line 44 Position 10.
Could you please explain to me what I am missing? Thanks.
Does your project have references to Telerik.Windows.Controls.dll and Telerik.Windows.Controls.Data.dll? The Telerik documentation for the RadDataFilter mentions that both of these references are necessary.
I was able to reproduce the error you were getting by trying to build a project that uses a RadDataFilter but which has references to only one of the two assemblies mentioned. When I added a reference to the second, and rebuilt, the error went away.
(Admittedly, this was with the Silverlight version of the controls. However, the WPF and Silverlight versions of the Telerik RadControls are built from the same source code, so I expect that the WPF version of the controls will behave the same.)
I have a shared project (C#) used by several other projects.
In VS2008, everything compiles fine. Now I convert all to VS2010, then two referencing projects complain that the shared dll not found
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sharedC="clr-namespace:Shared.Converter;assembly=Shared"
<Window.Resources>
<ResourceDictionary>
<sharedC:BooleanToHiddenVisibility x:Key="boolToVis"/>
...
VS2010 compiler complaint about sharedC: BooleanToHiddenVisibilty not found
the error msg is:
The tag 'BooleanToHiddenVisibility' does not exist in XML namespace 'clr-namespace:Shared.Convert; assembly=Shared'. Line 14 position 14
I compiled shared.dll first and compilation is successful.
I removed shared project from reference and add it back. Still the same error
I checked the path of referenced shared.dll, it is correct
Not sure what I missed.
Found it. After conversion, project used to target .NET framework 3.5, after conversion, it is changed to target .NET framework 3.5 client profile. I change it back to .NET 3.5 framework and it compiles successfully
I am using a base Window class in a WPF project. In the code behind C# file the assembly to the base type is referenced and fine. In the XAML is looks like this:
<MyNamespace:WindowBase x:Class="MyNamespace.Applications.UserInterface.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:MyNamespace="clr-namespace:MyNamespace.Somewhere;assembly=MyNamespace.Common"
Title="MainWindow" Height="350" Width="525">
<Grid>
</Grid>
The solution compiles fine and I can run it. I just can't use the designer in VS 2010. It throws the following exception: The type'MyNameSpace:WindowBase' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.
Well. they have been. I can't understand what this issue is. This particular base class is used in other projects just fine. I grabbed it for a new project and I can't use the designer. Very frustrating.
Found this problem just recently (this answer upgraded from a comment).
If you copy the dll from a network path, you must right click on the file in Windows Explorer, select Properties, then 'unblock'; there is a hidden NTFS stream associated with the file, and many files when you download from the 'net or copy from a network path, for security reasons.
Only the designer complains, yet the project builds and runs fine: weird isn't it?!
Whenever the designer is acting up against me - the first thing I do is clear the obj-folders in the project and rebuild. Sometimes they seem to go out of sync for some reason (usually when I'm drag-dropping a lot of files and renaming visual items).
I dont't know if its the same issue but in VS2008 I tried to make abstract UserControls but had to change this because the designer didnt't support any abstract base classes (however the solution was compilable and also worked as excpected).
Fixed. The library that contained my base class resided on a drive on the network that I did not have permissions to. That seemed to have no affect on VS 2008 as it worked, but VS 2010 apparently took exception to that when the designer tried to load it. Weird.