I want to hide and display a tab based on a IsVisible property on a QTab that will be bound in the RadTab's ItemSource.
Here are the classes I am using
MainPage.xaml.cs
xaml snippets
The above works so the binding is fine but when I add
To the style I get an error that says I cannot set a readonly property. Is there any way I can bind the the TabItems Visibility so I can dynamically had the tab.
Thanks
Here are the classes I am using
public
class
QTabs
{
public
ObservableCollection<QTab> Tabs {
get
;
set
; }
public
QTabs()
{
Tabs =
new
ObservableCollection<QTab>
(
new
QTab[] {
new
QTab { Header=
"Header 1"
,Value=
"Value 1"
},
new
QTab { Header=
"Header 2"
,Value=
"Value 2"
},
new
QTab { Header=
"Header 3"
,Value=
"Value 3"
, IsVisible= Visibility.Collapsed},
new
QTab { Header=
"Header 4"
,Value=
"Value 4"
},
new
QTab { Header=
"Header 5"
,Value=
"Value 5"
}
}
);
}
}
public
class
QTab
{
public
string
Header {
get
;
set
; }
public
string
Value {
get
;
set
; }
public
Visibility IsVisible {
get
;
set
; }
public
QTab()
{
IsVisible = Visibility.Visible;
}
}
MainPage.xaml.cs
public
MainPage()
{
AllTabs =
new
QTabs();
InitializeComponent();
DataContext =
this
;
}
<
my3:RadTabControl
x:Name
=
"tabscon"
Grid.Row
=
"1"
DataContext
=
"{Binding AllTabs}"
ItemsSource
=
"{Binding Tabs}"
>
<
my3:RadTabControl.ItemContainerStyle
>
<
Style
TargetType
=
"my3:RadTabItem"
>
<
Setter
Property
=
"HeaderTemplate"
>
<
Setter.Value
>
<
DataTemplate
>
<
TextBlock
Text
=
"{Binding Header}"
/>
</
DataTemplate
>
</
Setter.Value
>
</
Setter
>
</
Style
>
</
my3:RadTabControl.ItemContainerStyle
>
</
my3:RadTabControl
>
The above works so the binding is fine but when I add
<
Setter
Property
=
"Visibility"
Value
=
"{Binding IsVisible}"
/>
Thanks