我有一個每個狀態都有熱點的地圖(在Expression Blend中完成)。我捕獲每個MouseEnter狀態(1到50)。我傳遞到我的域名資料來源:上述使用域數據源將數據綁定到TextBlock
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))
工作正常,爲DataGrid,ListBox和甚至到數據形。
但我創建了一個帶有文本塊的彈出窗口。
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>
我如何獲得的TextBlocks顯示從_StateContext值。
StackPanel有DataContext但沒有ItemsSource。我錯過了什麼?
你的工作示例是什麼樣的?我很努力地想知道如何使用ListBox來代替彈出窗口。 – AnthonyWJones 2009-12-11 21:40:55
當然,州集合已經有你需要的狀態數據? – AnthonyWJones 2009-12-11 21:52:42