我应该让我的Prism观看一个特殊的View类吗?(Should I make my Prism views a special View class?)

编程入门 行业动态 更新时间:2024-10-24 18:20:12
我应该让我的Prism观看一个特殊的View类吗?(Should I make my Prism views a special View class?)

我通常只使用UserControl作为视图,但在这个项目中我认为从中派生一个View类可能会更好,并将其用作视图的“包含”类,以便以后可能会将更多功能注入到View 。 然而,我当时并没有使用Prism,所以我所拥有的奢侈品更少。

我应该保持这种做法,还是简单的UserControl视图足够?

I normally just use UserControl for a view, but during this project I thought it might be better to derive a View class from that, and use that as the 'containing' class for views, to allow me to possibly later inject more functionality into a View. However, I wasn't using Prism then, so I had much fewer luxuries etc. that an established framework brings.

Should I keep this practice, or are plain UserControl views ample enough?

最满意答案

我认为这是您的观点要求的问题。 正如您所说,这种方法使您可以灵活地为View类添加功能,并使其在所有视图中立即可用。

但是,由于View中的焦点通常放在最大化XAML并最小化代码隐藏(这是行为的一个很好的例子),我认为你的共同基础View类方法可能会以某种方式将你推向另一个方向。 无论你在课堂上投入什么,都要尝试通过XAML和行为来实现它。

I think that's a matter of the requirements for your Views. As you said, that approach gives you the flexibility of adding functionality to your View class and having it instantly available in all your Views.

However, as the focus in the View is usually put in maximizing the XAML and minimizing the code-behind (a good example for this are behaviors), I think your common base View class approach might somehow move you in the other direction. Whatever you'd put into that class, try to achieve it through XAML and behaviors.

更多推荐

本文发布于:2023-08-07 17:56:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1465115.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:类吗   View   Prism   class   special

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!