I am stuck with a simple Problem. I want to "port" the BasicMVVMQuickStart from Silverlight to WPF. I've Setup a new Project, imported files and references but can't get over a build error that states that the dependency from
System.Windows, Version=188.8.131.52, Culture=neutral, PublicKeyToken=7cec85d7bea7798e"
can't be resolved. I know thats a Silverlight assembly. I have a couple of copies of that dll but None with that version number and referencing one of these lead to another bunch of Errors due to double referencing.
Does anybody know where to find that specific Version of System.Windows.dll?
Nov 16, 2012 at 5:08 PM
As far as we know not all assemblies provide the ability to run on both Silverlight
and .NET runtimes. For example this could be the case of the
System.Windows.dll used in Silverlight applications. For more information about the binary compatibility support between
Silverlight and WPF you can check the following article:
Take into account that porting from one platform to the other might not always be straightforward as some features may not be available for both platforms and because of the differences between the
XAML in Silverlight and WPF. In some cases you may have to change the namespace used in your
Silverlight application to match the WPF equivalents. An example of this could be the
VisualStateManager class which in Silverlight
can be located in the System.Windows.dll assembly but its
WPF version is defined in the PresentationFramework.dll assembly.
You can find more detailed information about these differences in the following resources:
So far, we have been able to port the Basic MVVM QuickStart from
Silverlight to WPF following this:
Create a new WPF project named BasicMVVMApp. This is the same as name of the namespace used in the Basic MVVM QuickStart's classes. (You can name you
WPF project with a different name, but then you will have to change the namespace of the aforementioned classes manually.)
Add a reference to Microsoft.Practices.Prism
Modify the App.xaml to add the following resources:
Create two new folders in your WPF project, named Images and
Import the following files of the original Basic MVVM QuickStart:
- In your WPF project import the files: Questionnaire.cs, QuestionnaireView.xaml, QuestionnaireView.xaml.cs, QuestionnaireViewModel.cs.
- In your Images folder import the info.png file.
- In your Theme folder import the Theme.xaml file.
Open your MainWindow.xaml window and replace its XAML code with the contents of the
MainPage.xaml view of the original Basic MVVM QuickStart, including the namespaces. You should replace everything except for the
x:Class attribute of the MainWindow.xaml window.
Open the Theme.xaml file you imported before, and remove the following namespace:
Then, find any references to the aforementioned namespace inside this file and change them to use the default namespace which is set to use the
PresentationFramework.dll assembly. For example, you have to change:
<!-- to: -->
Finally, find the following styles inside the Theme.xaml file and change their
x:Name attribute to x:Key. This is because
Silverlight supports an x:Name on a ResourceDictionary item and can use
x:Name as a substitute for x:Key. However,
WPF does not support this behavior, and you have to use an x:Key instead.
I hope you find this useful,
That was really helpful - thanks a lot (I probably wouldn't have figured out all the differences by myself and would probably have given up on this sample).