如果我绑定到的属性(在这种情况下为上下文)是一个具有其属性 (Unit)的类(LatestReading 类) ,那么执行数据绑定的正确方法是什么。
数据上下文设置为类的根。这是我班级的层次结构。MonitoringPoint.LatestReading.Unit
<DataTemplate x:Key="TrackBallInfoTemplate"
DataType="{x:Type winGRAPH_Core:MonitoringNode}">
<StackPanel Margin="3">
<Grid Height="Auto">
<StackPanel Height="Auto"
VerticalAlignment="Top"
Orientation="Horizontal">
<TextBlock TextWrapping="Wrap"
Text="{Binding DataPoint.Value, FallbackValue=0.00}"
FontWeight="Bold"
FontSize="16" />
<TextBlock TextWrapping="Wrap"
Text="{Binding LatestReading.Unit, FallbackValue=°C}"
Margin="2,3,0,0" />
</StackPanel>
</Grid>
<Grid Height="Auto">
<TextBlock TextWrapping="Wrap"
Text="{Binding DataPoint.Category, FallbackValue=time}"
d:LayoutOverrides="Width, Height"
FontStyle="Italic"
Margin="0,2,0,0" />
</Grid>
</StackPanel>
</DataTemplate>