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