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
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
0
Accepted
Hello,
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:
You can find the last approach realized in the attached solution.
Kind regards,
Petar Mladenov
the Telerik team
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"
);
}
}
<
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
;
}
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:
Is this a bug or something else?
regards,
Richard Koslik
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
Hi,
Hristo
the Telerik team
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.
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
best regards
Richard Koslik