Windows Phone 7 中的按钮外观
我创建了一个派生按钮类,其中包含几个用于“正常”和“按下”状态的 ImageSource 成员。每当用户按下按钮时,我需要能够将图像更改为按下的图像。
环顾四周,我发现您可以在 xaml 中使用 VisualStateManager 来指定用于每个状态的位图。 Windows Phone 7 (WP7) 更改按钮的背景点击时的颜色
现在这一切都很好,但我需要能够动态地而不是在设计时做同样的事情。有没有办法在代码中做到这一点?
或者我可以覆盖一些事件处理程序并手动设置背景吗?似乎没有事件处理程序来捕获这个问题,从我读到的内容来看这是一个禁忌......
谢谢!
I have created a derived button class which contains a couple ImageSource members for the Normal and Pressed states. I need to be able to change the image to the Pressed image whenever the user presses the button.
Looking around I've noticed that you can use VisualStateManager in xaml to specify the bitmaps to use for each state. Windows Phone 7 (WP7) Change a button's background color on click
Now this is all fine and dandy, but I need to be able to do the same thing dynamically rather than at design time. Is there a way to do this in code?
Or can I override some event handler and set the background manually? Seems that there are no event handler to trap this and it's a no-no from what I read...
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以尝试以下操作:-
希望这有帮助...
You can try the following:-
Hope this helps...
您是否尝试过将每个状态的图像设置为控件中的属性?
Have you tried setting images for each state as properties in your control?