我有每个州的热点地图(在 Expression Blend 中完成)。我捕获状态的每个 MouseEnter(1 到 50)。我将它传递到我的域数据源中:
Dim activebox As Path = TryCast(sender, Path)
activebox.Fill = mouseOverColor
Dim StateID As Integer = CInt(Right(activebox.Name, 2))
Dim _StateContext As New StateContext
myDataGrid.ItemsSource = _StateContext.States
_StateContext.Load(_StateContext.GetStateByStateIDQuery(StateID.Text))
以上适用于数据网格、列表框甚至数据表单。
但是我创建了一个带有文本块的堆栈面板的弹出窗口。
popupStatesBox.DataContext = ??????????????
popupStatesBox.IsOpen = True 'popup does open but has no data
-- popupStatesBox.xaml
<Popup x:Name="popupStatsBox" Margin="8,35,0,8" DataContext="{Binding}" IsOpen="false" Width="268" HorizontalAlignment="Left"> <StackPanel x:Name="Layout" Background="Black"> <TextBlock x:Name="tbState" Text="{Binding StateName /> <TextBlock x:Name="tbAbbrev" Text="{Binding Abbreviation}" /> </StackPanel> </Popup>
如何让文本块显示 _StateContext 中的值。
StackPanel 有 DataContext 但没有 ItemsSource。我错过了什么?