如何使用从代码behing到WPF的变量(字符串/整数/双精度)

时间:2015-10-04 19:55:29

标签: .net wpf vb.net

如何使用从代码behing到WPF的变量(字符串/整数/双精度)?

例如,在我的情况下,我有这个故事板

          <Storyboard x:Key="volumerecdown">
                <DoubleAnimation Duration="00:00:00.5" AccelerationRatio="0.5" DecelerationRatio="0.5" 
                Storyboard.TargetProperty="Height" To="STRING_FROM_CODE_BEHIND"/>
          </Storyboard>

并且我想成为变量的STRING_FROM_CODE_BEHIND,或者它是来自代码隐藏的名称

我试图像这样声明字符串:

Public Property height_rec As String

但没有奏效

1 个答案:

答案 0 :(得分:0)

您必须使用财产。

    Private _height_rec As Integer
    Public Property height_rec As Integer
    Get
        Return _height_rec
    End Get
    Set(ByVal value As Integer)
        _height_rec = value
    End Set
    End height_rec 

并在xaml中提出以下内容:

 <Storyboard x:Key="volumerecdown">
                <DoubleAnimation Duration="00:00:00.5" AccelerationRatio="0.5" DecelerationRatio="0.5" 
                Storyboard.TargetProperty="Height" To="{Binding height_rec}"/>
          </Storyboard>