Hi guys, doing a trial on the SL suite and I've run into a show-stopper. Hoping somebody can help, because this seems like a basic requirement.
I'm using SL3, MVVM, Prism, latest telerik dlls.
I'm trying to bind a collection of business objects to a RadTabControl via an ObservableCollection. I need to use my own business objects in order to control the tab header rendering - i..e I need a closable tab whose header is generated at runtime with a "close" button to remove tabs. That all works aces.
Tabs display Charts, and users can spin up as many as they want. The business object exposes a Header, Chart (view), ChartID, and (most importantly) Selected (bool) and implementes INotifyPropertyChanged. When a new object is added to the collection I want it displayed in the tab control. No problem. However, it will not, no matter what I do, be set to IsSelected = true.
I have tried every conceivable variation of the following code:
With the Style implemented on the TabControl as:
Doesn't work. I get the old A_G_Parser Error error. I've put the "ContainerBinding" declaration here there and everywhere but it never resolves the problem.
I'd be happy just to have any newly added tabs selected automatically. What I'd really like is to have my Selected property in charge of this though. Any help is greatly appreciated of course.
Thanks - love the controls!
Kurt Mang - North Vancouver BC
I'm using SL3, MVVM, Prism, latest telerik dlls.
I'm trying to bind a collection of business objects to a RadTabControl via an ObservableCollection. I need to use my own business objects in order to control the tab header rendering - i..e I need a closable tab whose header is generated at runtime with a "close" button to remove tabs. That all works aces.
Tabs display Charts, and users can spin up as many as they want. The business object exposes a Header, Chart (view), ChartID, and (most importantly) Selected (bool) and implementes INotifyPropertyChanged. When a new object is added to the collection I want it displayed in the tab control. No problem. However, it will not, no matter what I do, be set to IsSelected = true.
I have tried every conceivable variation of the following code:
<UserControl.Resources> |
<conv:VisibilityConverter x:Key="VisibilityConverter" /> |
<telerik:ContainerBindingCollection x:Key="ClosableTabBindings"> |
<telerik:ContainerBinding PropertyName="IsSelected" Binding="{Binding Selected, Mode=TwoWay}" /> |
</telerik:ContainerBindingCollection> |
<!-- |
<ControlTemplate x:Key="TabItemTemplate" telerik:ContainerBinding.ContainerBindings="{StaticResource ClosableTabBindings}"> |
</ControlTemplate> |
--> |
<Style x:Key="ClosableTabStyle" TargetType="telerikNav:RadTabItem" telerik:ContainerBinding.ContainerBindings="{StaticResource ClosableTabBindings}"> |
<Setter Property="IsSelected" Value="{Binding}" /> |
<Setter Property="HeaderTemplate"> |
<Setter.Value> |
<DataTemplate> |
<StackPanel Orientation="Horizontal"> |
<TextBlock Text="{Binding Title}" |
Style="{StaticResource DataGridTextStyle}" /> |
<!-- |
<TextBlock Text="{Binding Selected}" |
Style="{StaticResource DataGridTextStyle}" /> |
--> |
<Button Content="x" |
Tag="{Binding ItemID}" |
Click="OnCloseTab" |
Margin="2" |
HorizontalAlignment="Right" |
VerticalAlignment="Center" /> |
</StackPanel> |
</DataTemplate> |
</Setter.Value> |
</Setter> |
<Setter Property="ContentTemplate"> |
<Setter.Value> |
<DataTemplate> |
<ContentControl Content="{Binding Chart}" /> |
</DataTemplate> |
</Setter.Value> |
</Setter> |
<!-- |
<Setter Property="IsSelected" Value="{Binding Selected, Mode=TwoWay, ElementName=telerikNav:RadTabItem}" /> |
--> |
</Style> |
</UserControl.Resources> |
<telerikNav:RadTabControl Name="tabCharts" |
ItemsSource="{Binding Charts}" |
ItemContainerStyle="{StaticResource ClosableTabStyle}" |
telerik:ContainerBinding.ContainerBindings="{StaticResource ClosableTabBindings}" |
DropDownDisplayMode="WhenNeeded" |
MinHeight="450" |
MinWidth="600" |
FontSize="10" |
HorizontalAlignment="Stretch" |
VerticalAlignment="Stretch" |
Margin="14" |
Grid.Row="0"> |
</telerikNav:RadTabControl> |
Doesn't work. I get the old A_G_Parser Error error. I've put the "ContainerBinding" declaration here there and everywhere but it never resolves the problem.
I'd be happy just to have any newly added tabs selected automatically. What I'd really like is to have my Selected property in charge of this though. Any help is greatly appreciated of course.
Thanks - love the controls!
Kurt Mang - North Vancouver BC