Alright, I'm doing something fairly complicated here, so bear with me. I have an object that makes queries to the server and returns a number of records for each query. I store the results in an ObservableCollection, and notify as soon as the first query returns, letting the collection update automatically with the resulting queries. As soon as I'm notified, I try to populate a TabControl with the appropriate data using templating/data binding. If I only have 1 query, it works fine, but if I have 2 or more, there's a problem. Tabs are created with the appropriate headers, making it appear as though the binding is working, but If I click on one that's not selected, the content is not displayed (it remains the content from the 1st result). If I then try to go back to the first tab, all content disappears. Below are the templates I'm using and the code I'm calling to do the binding. I know for sure it's only hitting my custom transformer once, because I tried setting a breakpoint there. Anyone have any ideas?
<Application.Resources> |
<Style TargetType="telerik:RadTabItem" x:Key="LayerTabItem"> |
<Setter Property="HeaderTemplate"> |
<Setter.Value> |
<DataTemplate> |
<TextBlock Text="{Binding Layer.Name}" /> |
</DataTemplate> |
</Setter.Value> |
</Setter> |
<Setter Property="ContentTemplate"> |
<Setter.Value> |
<DataTemplate> |
<telerik:RadTabControl AllowDragReorder="True" SelectedIndex="{Binding ActiveRecordIndex}" ItemsSource="{Binding Records}" ItemContainerStyle="{StaticResource RecordTabItem}"> |
</telerik:RadTabControl> |
</DataTemplate> |
</Setter.Value> |
</Setter> |
</Style> |
<Style TargetType="telerik:RadTabItem" x:Key="RecordTabItem"> |
<Setter Property="HeaderTemplate"> |
<Setter.Value> |
<DataTemplate> |
<TextBlock Text="{Binding ID}" /> |
</DataTemplate> |
</Setter.Value> |
</Setter> |
<Setter Property="ContentTemplate" Value="{StaticResource ItemTemplate}" /> |
</Style> |
<DataTemplate x:Key="ItemTemplate"> |
<Border BorderThickness="3,3,3,3" CornerRadius="5,5,5,5" Width="400" Height="200" VerticalAlignment="Stretch"> |
<Border.BorderBrush> |
<LinearGradientBrush EndPoint="0.986999988555908,0.958999991416931" StartPoint="0.0130000002682209,0.0230000000447035"> |
<GradientStop Color="#FFFFFFFF"/> |
<GradientStop Color="#FFFFFFFF" Offset="1"/> |
<GradientStop Color="#FFF2F2F2" Offset="0.51700001955032349"/> |
<GradientStop Color="#FF707070" Offset="0.27000001072883606"/> |
<GradientStop Color="#FF474747" Offset="0.76800000667572021"/> |
</LinearGradientBrush> |
</Border.BorderBrush> |
<Border.Background> |
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> |
<GradientStop Color="#FF080808"/> |
<GradientStop Color="#FFFFFFFF" Offset="1"/> |
</LinearGradientBrush> |
</Border.Background> |
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Hidden" Content="{Binding Converter={StaticResource ItemConverter}}"></ScrollViewer> |
</Border> |
</DataTemplate> |
</Application.Resources> |
<Grid x:Name="LayoutRoot"> |
<telerik:RadWindow Name="IdentifyBalloon" Header="Property Info" WindowStartupLocation="Manual" WindowAnimation="OnShow" CloseMode="Hide" ResizeMode="NoResize"> |
<telerik:RadTabControl AllowDragReorder="True" ItemContainerStyle="{StaticResource LayerTabItem}"> |
</telerik:RadTabControl> |
</telerik:RadWindow> |
</Grid> |
public void Select(IdentifyStackObserver stackObserver, RadWindow window) |
{ |
pixPoint = stackObserver.PixelPosition; |
ObservableCollection<IdentifyLayer> layers = stackObserver.Layers; |
string activeLayerName = stackObserver.ActiveLayer.Name; |
RadTabControl tabControl = window.Content as RadTabControl; |
IdentifyLayer[] layersCopy = new IdentifyLayer[layers.Count]; |
int selectedIndex = 0; |
for (int i = 0; i < layers.Count; i++) |
{ |
layersCopy[i] = layers[i]; |
if (layers[i].Layer.Name.Equals(activeLayerName)) |
selectedIndex = i; |
} |
tabControl.ItemsSource = layers; |
layers.Clear(); |
for (int i = 0; i < layersCopy.Length; i++) |
layers.Add(layersCopy[i]); |
tabControl.SelectedIndex = selectedIndex; |
if (!window.IsOpen) |
{ |
window.Opened += PositionWindow; |
//window.Show(); |
Application.Current.RootVisual.Dispatcher.BeginInvoke(window.Show); |
} |
else |
{ |
PositionWindow(window, null); |
} |
} |