Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/274.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将值绑定到wpf中的数据模板listbox itemtemplate中的标签_C#_Wpf_Xaml_Data Binding - Fatal编程技术网

C# 将值绑定到wpf中的数据模板listbox itemtemplate中的标签

C# 将值绑定到wpf中的数据模板listbox itemtemplate中的标签,c#,wpf,xaml,data-binding,C#,Wpf,Xaml,Data Binding,XAML 您已经绑定到视图模型属性hrvalueinitially。只需更改该属性的值。hrvalueinitially是如何定义的?我更改了属性值。最初,hrvalueinitially声明为全局变量。类似于double hrvalueinitially;静止的嗯,这对装订没什么好处。如何定义索引列表?最好将属性代码编辑到问题中,如果列表中的项目具有特定类型,请包含类型定义的相关部分。 <ListBox ItemsSource="{Binding ListOfIndexes}" Ho

XAML


您已经绑定到视图模型属性
hrvalueinitially
。只需更改该属性的值。
hrvalueinitially
是如何定义的?我更改了属性值。最初,hrvalueinitially声明为全局变量。类似于double hrvalueinitially;静止的嗯,这对装订没什么好处。如何定义索引列表?最好将属性代码编辑到问题中,如果列表中的项目具有特定类型,请包含类型定义的相关部分。
<ListBox ItemsSource="{Binding ListOfIndexes}"   HorizontalContentAlignment="Left"  x:Name="lstbxindex" SelectionMode="Extended" Foreground="White" FontSize="20px" Height="201" BorderBrush="#555555" Margin="80,40,0,0" VerticalAlignment="Top" Width="282" Background="#555555" >
     <ListBox.ItemTemplate>
        <DataTemplate>
            <StackPanel Orientation="Horizontal" >
                  <Label x:Name="lblhr"  Height="40px" Width="80px" Content="{Binding Path=hrvalueinitially}" FontSize="20px" HorizontalAlignment="Left" Background="#555555"  Foreground="White"></Label>
                  <TextBlock x:Name="items"  Text="{Binding}" Margin="35,0,0,0"></TextBlock>
            </StackPanel>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>
 private void dispatcherTimer_Tick(object sender, EventArgs e)
 {
    //check the listbox items is selected or not 
    if (lstbxindex.SelectedIndex > 0)
    {
        if (dispatcherTimer.Interval == TimeSpan.FromSeconds(3))
        {
            double hrvalue = 0.25 + hrvalueinitially;

            //lblhr.Content= hrvalueinitially;
            hrvalueinitially = hrvalue;
        }

     }
 }