简体   繁体   English

单击后如何更改用户控件的外观

[英]how to change appearance of a user control after it is clicked

I'm a beginner program designer so please go easy on me! 我是一名初学者程序设计师,所以请放轻松!

I want to change the appearance of my user control when the click event fires. 我想在点击事件触发时更改用户控件的外观。 It's a custom user control designed to show a 'Logged In' status that is green or a 'Logged out' status that is red. 这是一个自定义用户控件,旨在显示绿色的“已登录”状态或红色的“已注销”状态。 I need the stroke and fill to change from red to green when clicked and vice versa, as along with either a red cross icon or green tick icon. 我需要笔触和填充在单击时从红色更改为绿色,反之亦然,以及红色十字图标或绿色对勾图标。

I can do it manually in the xaml but not sure how to make it fire in the code behind? 我可以在xaml中手动完成操作,但不确定如何在后面的代码中触发它吗?

Preferred solution is to separate visuals from logic. 首选解决方案是将视觉与逻辑分离。 In this case, create appropriate state for your control in xaml using visual state , and change your control's state with this method . 在这种情况下,请使用可视状态在xaml中为控件创建适当的状态,并使用此方法更改控件的状态。

在事件处理程序上(如果您知道它是什么),请创建您的usercontrol实例并更改属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM