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

使用 适配器模式

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

上一篇:面向服务的体系架构 SOA(二) --- 服务的路由和负载均衡


下一篇:腾讯Ubuntu云虚拟主机设置ftp服务器