This is a migrated thread and some comments may be shown as answers.

Problem with actual version 2011.3.1116.1040 of Silverlight Tabcontrol

4 Answers 100 Views
TabControl
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Richard Koslik
Top achievements
Rank 1
Richard Koslik asked on 19 Dec 2011, 04:23 PM
Hello!

Some days ago I installed the newest version of Silverlight controls and afterwards I changed my TabControl (Microsoft-SDK) to a RadTabControl.

My situation is now the following:
I use the RadTabControl for changing between my overview (RadGridView) and the details of the selected data item. I have now a bounded variable for the property "SelectedIndex" of the RadTabControl. If this index changes from 0 to 1, I check in the setter of the binding variable, if the SelectedDataItem is null or not. If it is null then I set my binding variable again to 0.
My problem is now that I can set the binding variable to 0, but it is not done / not shown ... I am still on the detail page.

Is this a bug or is there a difference between the normal TabControl and the RadTabControl?

best Regards,
Richard Koslik

4 Answers, 1 is accepted

Sort by
0
Accepted
Petar Mladenov
Telerik team
answered on 22 Dec 2011, 01:28 PM
Hello,

 We managed to reproduce this behavior and it is expected in RadTabControl. In the RadTabControl's logic we have re-insured, that in a "property bound to SelectedIndex" 'setter re-setting this property is not allowed. However, this could be workarounded, for example like so (really bad workaround):

public int CurrTabIndex
     {
         get { return _currtabIndex; }
         set
         {
             if (value == 1 && this.CurrEmployee == null)
             {
                 Application.Current.RootVisual.Dispatcher.BeginInvoke(() =>
                     {
                         CurrTabIndex = 0;
                     });
                  
                 return;
             }
             _currtabIndex = value;
             this.OnPropertyChanged("CurrTabIndex");
         }
     }
 However, we suggest you use the PreviewSelectionChanged event or another MVVM approach - you can bind the IsEnabled of the RadTabItem to the CyrrentItem property of that is bound to the Currentitem of the GridView like so:
<telerik:RadTabControl x:Name="tabControl" SelectedIndex="{Binding CurrTabIndex, Mode=TwoWay}">
        <telerik:RadTabItem Header="MainTab">
            <telerik:RadGridView ItemsSource="{Binding Employees}" SelectedItem="{Binding CurrEmployee, Mode=TwoWay}"/>
        </telerik:RadTabItem>
 
        <telerik:RadTabItem Header="Info Tab" IsEnabled="{Binding Path=CurrEmployee, Converter={StaticResource converter} }">
public class SampleConverter: IValueConverter
   {
       public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
       {
           if (value == null)
           {
               return false;
           }
           return true;
       }
You can find the last approach realized in the attached solution. Kind regards,
Petar Mladenov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Richard Koslik
Top achievements
Rank 1
answered on 10 Jan 2012, 07:59 AM
Hello,

thanks for your help. I tried it now with the "PreviewSelectionChanged"-Event and it works fine, but I have one problem.

I have a RadTabControl with two tabitems. On the second tabitem I have also placed a RadTabControl (Child). If I change now the SelectedIndex of the second RadTabControl (Child) the "PreviewSelectionChanged"-Event of the main-Tabcontrol is also executed, WHY??

I bound the Event like this, I also tried it in code-behind, but it is always the same problem:
<telerik:RadTabControl x:Name="tabControl1" SelectedIndex="{Binding iTabIndex,Mode=TwoWay}">
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="PreviewSelectionChanged">
                    <cmd:EventToCommand Command="{Binding evPreviewSelChangedTC, Mode=OneWay}" PassEventArgsToCommand="True" />
                </i:EventTrigger>
            </i:Interaction.Triggers>

Is this a bug or something else?


regards,
Richard Koslik



0
Hristo
Telerik team
answered on 12 Jan 2012, 03:29 PM
Hi,

PreviewSelectionChanged and SelectionChanged events are routed events which means they bubble up the visual tree. Thus you can hear them in the parent TabControl when they are fired by the inner TabControl.

All the best,
Hristo
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Richard Koslik
Top achievements
Rank 1
answered on 17 Jan 2012, 02:41 PM
Ok, thanks for the information.


best regards

Richard Koslik
Tags
TabControl
Asked by
Richard Koslik
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Richard Koslik
Top achievements
Rank 1
Hristo
Telerik team
Share this question
or