更新时间:2022-12-10 22:31:43
无需转换。您可以直接绑定到编曲[0]
像这样
No need for the converter. You can bind directly to Arr[0]
like this
<TextBlock Name="testBox" Text="{Binding Path=Arr[0]}"/>
在编曲
元素需要实现 INotifyPropertyChanged的
虽然以动态更新。
The elements in Arr
would need to implement INotifyPropertyChanged
though in order to dynamically update.
更新:为了详细一点:
Update: To elaborate a bit more:
public class MyDouble : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private double _Value;
public double Value
{
get { return _Value; }
set { _Value = value; OnPropertyChanged("Value"); }
}
void OnPropertyChanged(string propertyName)
{
var handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(propertyName));
}
}
}
然后
ObservableCollection<MyDouble> Arr { get; set; }
和绑定到
<TextBlock Name="testBox" Text="{Binding Path=Arr[0].Value}"/>