单击我的按钮时更改样式 [英] Change Style When click on My Button
本文介绍了单击我的按钮时更改样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
向大家问好
我想在单击按钮时更改按钮的样式
例如:
-------------------------------------------
hello to all
i want change style my button when i click on the button
example:
-------------------------------------------
bool k=false;
private void button1_Click()
{
if(k)
{
button1.style=style1;
k=false;
}
else
{
button1.style=style1;
k=true;
}
}
-------------------------------------------
谢谢
-------------------------------------------
Thanks
推荐答案
从中学习..
http://social.msdn.microsoft.com/Forums/zh/wpf/thread/8fa8c8b3-ba23-4eac-8ad1-556e4da71dc9 [ http://stackoverflow.com/questions/3821573/change-a-style-dynamically- in-wpf [ ^ ]
点击并悬停时WPF背景发生变化 [ ^ ]
http://www.pcreview.co.uk/forums/button-background- changes-wpf-t3664967.html [ ^ ]
learn from these..
http://social.msdn.microsoft.com/Forums/en/wpf/thread/8fa8c8b3-ba23-4eac-8ad1-556e4da71dc9[^]
http://stackoverflow.com/questions/3821573/change-a-style-dynamically-in-wpf[^]
WPF background changes when click and hover[^]
http://www.pcreview.co.uk/forums/button-background-changes-wpf-t3664967.html[^]
坦克ridoy
------------------------------
但我在MyProject中有两个样式.
我不更改按钮的背景.我通过BLEND
创建并设计了自己的样式(Style1和Style2) 我想在用户按下按钮(设置样式1)和重复(设置样式2仅此按钮)时更改按钮样式.
------------------------------
代码按钮:
私有void Butto1_Click()
{
This.TopMost =!((bool)this.TopMost);
/*****,当Form1.TopMost = True设置Style1(并保存)时*****/
/*****并且当Form1.TopMost = False设置Style2(并保存)******/
}
------------------------------
非常坦克.
tanks ridoy
------------------------------
but i have two Style in MyProject.
I dont change background my button. i created and Design my styles (Style1 and Style2) By BLEND
i want change style my button when user pressed button (set style1) AND when Repeted(set Style2 only this not more).
------------------------------
code button:
Private void Butto1_Click()
{
This.TopMost = !((bool)this.TopMost);
/***** when Form1.TopMost=True set Style1 (and Save) *****/
/***** And when Form1.TopMost=False set Style2 (and Save) ******/
}
------------------------------
very tanks.
这篇关于单击我的按钮时更改样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文