如何在滑块值更改时使 TextBlock.Text = Slider.Value
我已经尝试过了,
If Slider1.Value = 1 Then
TextBlock1.Text = "1"
End If
If Slider1.Value = 2 Then
TextBlock1.Text = "2"
End If
If Slider1.Value = 3 Then
TextBlock1.Text = "3"
End If
If Slider1.Value = 4 Then
TextBlock1.Text = "4"
End If
If Slider1.Value = 5 Then
TextBlock1.Text = "5"
End If
实际上我遇到了一些错误,特别是当我有
If Slider1.Value = 1 Then
TextBlock1.Text = "1"
End If
代码时,因为程序运行时它已经是值 1 了。我是 WPF 新手,真的不知道在这里要做什么,所以请您向我展示或提供有关如何完成的代码示例,谢谢。
而且我已经使用表达混合 4 几天了,我知道如何创建模板并在鼠标悬停时为淡入淡出动画以及按钮的内容,但如果用户单击按钮,我将如何为单独的图片框或图像制作动画淡入或淡出,请给我一个例子,谢谢大家:)。
I've tried this
If Slider1.Value = 1 Then
TextBlock1.Text = "1"
End If
If Slider1.Value = 2 Then
TextBlock1.Text = "2"
End If
If Slider1.Value = 3 Then
TextBlock1.Text = "3"
End If
If Slider1.Value = 4 Then
TextBlock1.Text = "4"
End If
If Slider1.Value = 5 Then
TextBlock1.Text = "5"
End If
I actually get a couple of errors with this, especially when i have the
If Slider1.Value = 1 Then
TextBlock1.Text = "1"
End If
code because it's already on value 1 when the program runs. I'm new to WPF and don't really know what to do here so i you could please show me or provide a code sample on how it's done thanks.
and also i have been using expression blend 4 for a couple of days and i know how to create a template and animate fades on mouse over and stuff for a button but say if the user clicks a button how would i animate a separate picturebox or image to fade in or fade out could you please provide me an example thankyou everyone :).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不需要在代码隐藏中执行此操作,只需绑定到 XAML 中的值,如果您想以某种方式修改该值,请使用 ValueConverter。
请参阅 http://msdn.microsoft.com/en- us/library/system.windows.data.ivalueconverter.aspx
否则,如果您确实想在 CodeBehind 中执行此操作,请使用 ValueChangedEvent:
XAML:
代码隐藏
You don't need to do this in Codebehind just bind to your value in XAML and if you want to modify that value somehow, then use a ValueConverter.
see http://msdn.microsoft.com/en-us/library/system.windows.data.ivalueconverter.aspx
Otherwise if you definitely want to do it in CodeBehind use the ValueChangedEvent:
XAML:
CodeBehind