Sharing Code Between Silverlight and WPF

一个很好的列子:

http://www.codeproject.com/Articles/254506/XAMLFinance-A-Cross-platform-WPF-Silverlight-WP7-A

使用MVVM

The WPF solution has much the same structure as the Silverlight one; however, all of the ViewModel, View and Resource files are included as links, as per the steps described above.

Resolution Techniques

1.Conditional compilation (#if)

  private string ReadFileToString(string filename)
  {

#if !SILVERLIGHT

    using (var stream = this.GetType().Assembly.GetManifestResourceStream(
      "SLUGUK.ViewModel." + filename))
    {
      StreamReader reader = new StreamReader(stream);
      string xml = reader.ReadToEnd();
      return xml;
    }

#else

    string path = "/SilverlightTwitterApp;component/ViewModel/" + filename;
    Uri uri = new Uri(path, UriKind.Relative);
    StreamResourceInfo sri = Application.GetResourceStream(uri);
    StreamReader reader = new StreamReader(sri.Stream);
    string xml = reader.ReadToEnd();
    return xml;

#endif
  }

2.Partial classes

3.Design Patterns

使用 适配器模式

对于新的系统,会有多点触控技术。能把任务分解为两个方面的工作,一是同时采集多点信号,二是对每路信号的意义进行判断,也就是所谓的手势识别,从而实现屏幕识别人的五个手指同时做的点击、触控动作。

原文地址:https://www.cnblogs.com/qianblue/p/3431438.html