表面按钮模板绑定 [英] surface button template binding

查看:72
本文介绍了表面按钮模板绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,

我正在研究micrsoft桌子上的项目
但我陷入无法解决的问题

我正在使用模板来更改按钮的形式
但我也想将按钮更改为另一种形式
当事件发生时(在c#或xaml中)或更具体地,当我第二次按下按钮时

有人可以帮我吗?

Nico

解决方案

您要它只是更改还是设置动画?我通过创建透明控件并在其上绘制所需的轮廓来创建不规则形状的窗口和按钮.唯一的问题是,我从未找到一种方法可以将一个轮廓动画化为另一个轮廓.


不要按"answer"来提问,对我的回复发表评论,或编辑您的信息.

如果只想更改它,则必须在代码中进行操作,但是该按钮在第二次被按下"时没有可模板化的状态,不过,您可以为诸如mousedown之类的状态创建模板.

要在运行时更改模板,请看一下它应该与您想要的内容非常相似:
http://codingbandit.com/Blog/blog /wpf-data-templates-part-3-switching-data-templates-at-runtime/ [ <Style x:Key="Field" TargetType="{x:Type Label}">...</Style><br />



像这样的一些代码隐藏(我的代码恰好在VB中-尽管转换为C#不应太难):

<br />
lblPhone.Style = CType(Me.Resources("rField"), Style)<br /><br />
lblPhone.Style = CType(Me.Resources("Field"), Style)<br />



希望有帮助.


dear all,

i am working on a project on the micrsoft surface table
but i am stuck with something i can''t solve

i am using a template to change the form of my button
but i would also want to change the button into another form
when an event occurs(in c# or xaml) or more specifically when i press the button the second time

can someone help me?

Nico

Do you want it to just change, or to animate ? I create irregular shaped windows and buttons by creating transparent controls and drawing the outline I want on them. The only issue is, I''ve never found a way to animate from one outline to another.


Don''t push ''answer'' to ask questions, comment on my reply, or edit your post.

If you just want it to change, you will have to do it in code, the button has no templatable state for ''the second time it was pushed'', you can create a template for states like mousedown, though.


For changing the template at runtime take a look at this should be fairly similar to what you want:
http://codingbandit.com/Blog/blog/wpf-data-templates-part-3-switching-data-templates-at-runtime/[^]

You could easily then detect the second press of the button with a counter and then trigger the template change like the above.

Styles work in basically the same way I have two styles declared in the Window.Resources section of my window that look like this:

<Style x:Key="rField" TargetType="{x:Type Label}">...</Style><br /><br />
<Style x:Key="Field" TargetType="{x:Type Label}">...</Style><br />



And some code-behind like this (mine happens to be in VB - though converting to C# shouldn''t be too hard):

<br />
lblPhone.Style = CType(Me.Resources("rField"), Style)<br /><br />
lblPhone.Style = CType(Me.Resources("Field"), Style)<br />



Hope that helps.


这篇关于表面按钮模板绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆