Binding Data to a TextBlock using Domain Data Source

Posted by TFisher on Stack Overflow See other posts from Stack Overflow or by TFisher
Published on 2009-12-11T20:06:31Z Indexed on 2010/04/06 16:03 UTC
Read the original article Hit count: 456

Filed under:
|
|
|

I have a map with hotspots for each state (done in Expression Blend). I capture each MouseEnter of the state (1 thru 50). I pass that into my Domain Data Source:

    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))

The above works fine for a datagrid, listbox and even a dataform.

But I created a popup with a stackpanel that has textblocks.

    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>

How do I get the textblocks to display the values from the _StateContext.
StackPanel has DataContext but no ItemsSource. What am I missing?

© Stack Overflow or respective owner

Related posts about Silverlight

Related posts about binding