自定义UserControl的实例 [英] Customizing Instances of a UserControl
问题描述
使用案例: 我有一个UserControl,上面有一个导航到特定页面的按钮。
Use Case: I have a UserControl with a button on it that navigates to a particular page.
我想重用这个控件,但希望按钮导航到不同的位置,具体取决于它的页面已打开。
I want to reuse this control, but would like the button to navigate to a different place depending on what page it is on.
覆盖实例按钮操作的最佳方法是什么? 我应该创建一个可以在XAML实例中设置的属性吗? 关于如何做到这一点的提示表示赞赏。
What is the best approach to overriding the button action for an instance? Should I create a property I can set in the XAML instance? Tips on how to do this are appreciated.
推荐答案
我也会推荐您可以在UserControl上使用属性,您可以在UC上设置不同的属性,具体取决于它在网站上的位置。
I also would recommend you to use Properties on the UserControl which you can set differently on the UC, depending where it's placed on the Site.
这篇关于自定义UserControl的实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!