Quantcast
Channel: patterns & practices: Prism
Viewing all articles
Browse latest Browse all 1878

New Post: Reference to System.Windows.dll missing while porting the BasicMVVMQuickStart to WPF

$
0
0

Hi Peter,

As far as we know not all assemblies provide the ability to run on both Silverlightand .NET runtimes. For example this could be the case of theSystem.Windows.dll used in Silverlight applications. For more information about the binary compatibility support betweenSilverlight 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 theXAML in Silverlight and WPF. In some cases you may have to change the namespace used in yourSilverlight application to match the WPF equivalents. An example of this could be theVisualStateManager 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 fromSilverlight to WPF following this:

  1. 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 youWPF project with a different name, but then you will have to change the namespace of the aforementioned classes manually.)

  2. Add a reference to Microsoft.Practices.Prism

  3. Modify the App.xaml to add the following resources:

    <ResourceDictionary><ResourceDictionary.MergedDictionaries><ResourceDictionarySource="Theme/Theme.xaml"/></ResourceDictionary.MergedDictionaries></ResourceDictionary>
  4. Create two new folders in your WPF project, named Images andTheme.

  5. 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.
  6. Open your MainWindow.xaml window and replace its XAML code with the contents of theMainPage.xaml view of the original Basic MVVM QuickStart, including the namespaces. You should replace everything except for thex:Class attribute of the MainWindow.xaml window.

  7. Open the Theme.xaml file you imported before, and remove the following namespace:

    • xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"
  8. Then, find any references to the aforementioned namespace inside this file and change them to use the default namespace which is set to use thePresentationFramework.dll assembly. For example, you have to change:

    <vsm:VisualStateManager.VisualStateGroups><!-- to: --><VisualStateManager.VisualStateGroups>
  9. Finally, find the following styles inside the Theme.xaml file and change theirx:Name attribute to x:Key. This is because Silverlight supports an x:Name on a ResourceDictionary item and can usex:Name as a substitute for x:Key. However, WPF does not support this behavior, and you have to use an x:Key instead.

    • QuestionLabelStyle
    • ToolTipImageStyle
    • BorderBrush
    • HeaderedBorderStyle

I hope you find this useful,

Damian Cherubini
http://blogs.southworks.net/dcherubini


Viewing all articles
Browse latest Browse all 1878

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>