Silverlight和WPF的相同XAML代码 [英] Same XAML code for silverlight and WPF

查看:73
本文介绍了Silverlight和WPF的相同XAML代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在Silverlight和WPF应用程序中使用通用代码(XAML和业务代码)吗?我认为我可以轻松实现业务逻辑,那么XAML呢?

我的计划是

1.首先将会制作一个基于XAML的用户控件(这将是主要容器,其中包含所有其他子控件)并放置在类库中

2.创建一个Silverlight项目并使用类库中的用户控件

3.创建另一个WPF项目并使用类库.

我认为,这样我可以为它制作一个通用的UI/业务层代码.这行得通吗?这是个好习惯吗?

解决方案

我认为这种做法会很好,但是您必须保持警惕,以应对WPF和Silverlight的差异.

例如,您可以在WPF中使用触发器,但不能在Silverlight中使用.然后,与WPF相比,Silverlight具有很多安全性,因此WPF要求两者有所区别.但是从理论上讲,您肯定可以构建一个.然后将其用于其他.但 我很确定您必须进行一些更改才能使其看起来正确.


Can I use common code (XAML and Business code) for Silverlight and WPF application? I think business logic I can easily make it, what about XAML?

my plan is

1. first  will  make a XAML based user control (this will be the main container and it contain's all other child controls) and place in a class library

2. Create a Silverlight project and use the user control from the class library

3. Create another WPF project and use the class library.

I think so that I can make a common UI/Business layer code for same.. Is it works? Is it a good practice?

解决方案

I think the practice will be fine, but you have to keep your head up for differences on the WPF and Silverlight.

For instance you can use Triggers in WPF, but not in silverlight. And then Silverlight has alot of security compared to WPF, which calls for differences on the two. But in theory you could surely build the one. And the use it for the other afterwards. But i am quite sure you will have to do some changes to make it seem right.


这篇关于Silverlight和WPF的相同XAML代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆