I have set the visibility attribute to a binding value, but when the view is loaded or when the view model is loaded the first content of the rabtabitem content (<telerik:RadTabItem.Content> ) still be visible (the header is hide).
If I hide an another one, it's work fine.
do you have a work around for this ?
My xaml code:
<telerik:RadTabItem Height="Auto" x:Name="RibTab" Visibility="{Binding IsCompteAuthorizedForRead, Source={StaticResource banqueSocieteViewModel}}" >
Best regards.
D.Collin
10 Answers, 1 is accepted
We tried to reproduce this but we did not manage. Could you please check out our test project and let us know if we have missed something? We also wondered what is the exact version of RadControls that you use. Thank you in advance for your cooperation.
Regards,
Petar Mladenov
the Telerik team
thanks for your answer.
I use the version 2010.3.1110.1040 of the component.
I have made some changes in your project to show my difficuties, you will see in the attached file the xaml code and the code behind of the mainpage (i cant sent to you the updated project due to your file limitation policy).
On tab item "a", you'll see a blue rectangle, on tab item "b", you'll see a red rectangle.
if tab item "a" have a visibilty attribute set to collapsed, you'll see that the header "tab item a" is hidden but not the content and the blue rectangle is still visible (see telerik3.png)...
Best regards
D.Collin
This issue could be easily fixed with the RadTabControl from Q2 2011 with setting the IsDefaultitemSelected property to false. The problem actually comes from the fact that the first RadTabItem is selected by default.
Unfortunately, this property does not exist in the Q3 2010 nor you can set the IsSelected = false in order to resolve this.
Kind regards,
Petar Mladenov
the Telerik team
I'm also facing a problem regarding this issue.
The problem is that when you hide a tab, the content "pane" remains visible because the hidden tab apparently stays selected.
Your solution with setting the isdefaultselected to false does not work for me.
I have a tabcontrol and depending on an external selection mode tab items are shown or hidden
Mode A
- 1,2,3 are shown, the rest is hidden
Mode B
- 2, 4, 5 are shown, the rest is hidden
I would like the behaviour to be that hidden tabs can not be "selected" and the first available tab will be selected instead when hiding a selected tab. Is this possible?
For now I've fixed it like this, but it does not feel necessary
var tabControl = (RadTabControl)_view.FindName("NameXyz");
var tabItems = tabControl.Items.Cast<RadTabItem>().ToList();
var firstVisible = tabItems.FirstOrDefault(t => t.Visibility == Visibility.Visible);
if (firstVisible != null && tabItems[tabControl.SelectedIndex].Visibility == Visibility.Collapsed)
{
tabControl.SelectedIndex = tabItems.IndexOf(firstVisible);
}
Your workaround is correct and we think that using the SelectedIndex is a correct way to go in this scenario.
We can also suggest you to use databinding and ViewModel. Instead of hiding / showing an items, you can remove/add the corresponding ViewModels. If using similar approach you can take advantage of the SelectedItemRemoveBehavior property and set it to SelectFirst, SelectLast, SelectNext, SelectPrevious or SelectNone (supposing the current is the removed one).
Petar Mladenov
the Telerik team
i have a one issue with using of RadTabItem.
i am setting the IsHitTestVisible is false to TadTabItem.so it wont alow me to select the tabitem.its fine
but my RadTabItem.header part i have one checkbox.
i dont want user to select the tabitem so only i am making the ishittestviewsible as flase.but i need to allow the user to check or uncheck the checkbox which is located the radtabitem.header section.
advance tanx.
If you need to use the CheckBoxes in the Header, you cannot use IsHitTestVisible = False. In order to prevent a selection, you can take advantage of the PreviewSelectionChanged event and set e.Handled = true.
Kind regards,Petar Mladenov
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
tanx for ur quick rly.the preventselection event wont be work in my case.y bcoz that wont alow me to select any tabitem .but my case i dont want selection only in the tabitem whihc is having checkbox in the header.
please try to give the solution in that way.
adnavce tax
Please take a look at the attached project. It shows RadTabControl with 5 RadTabItems - 2 with CheckBoxes and 3 with simple strings in the Header:
<
telerik:RadTabControl
PreviewSelectionChanged
=
"RadTabControl_PreviewSelectionChanged"
>
<
telerik:RadTabItem
>
<
telerik:RadTabItem.Header
>
<
StackPanel
>
<
CheckBox
/>
<
TextBlock
Text
=
"Item A"
/>
</
StackPanel
>
</
telerik:RadTabItem.Header
>
</
telerik:RadTabItem
>
<
telerik:RadTabItem
>
<
telerik:RadTabItem.Header
>
<
StackPanel
>
<
CheckBox
/>
<
TextBlock
Text
=
"Item A"
/>
</
StackPanel
>
</
telerik:RadTabItem.Header
>
</
telerik:RadTabItem
>
<
telerik:RadTabItem
Header
=
"Item C"
/>
<
telerik:RadTabItem
Header
=
"Item D"
/>
<
telerik:RadTabItem
Header
=
"Item E"
/>
</
telerik:RadTabControl
>
private void RadTabControl_PreviewSelectionChanged(object sender, Telerik.Windows.Controls.RadSelectionChangedEventArgs e)
{
if ((e.AddedItems[0] as RadTabItem).Header is StackPanel)
{
e.Handled = true;
}
}
Please let us know if this helps you proceed further. All the best,
Petar Mladenov
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
i think some where i missed somehting so only its not worked when i tried.now its working awesom.
tan q