Hello.
I'm using Q1 2010 for WPF.
I have this following simple sample:
As you can see, there is one RadTabControl with one RadTabItem. I've modified RadTabItem header through ItemContainerStyle. There is only one button in HeaderTemplate. I've used RoutedEventHandler class for allowing the button's click events to be catched.
Here is the code:
Everything works fine with one exception. If I put another Button as RadTabItem Content (as you can see in the above xaml example) and I set property of this button "IsDefault = true", the click events from the first button in RadTabItem header are not fired.
Is this behavior correct ?
I have also second question:
Imagine almost the same situation as in the previous example. I've RadTabItem with modified HeaderTemplate with one button in it. I've no buttons in the RadTabItem Content, so when I click on Button in my RadTabItem header, the click event is fired correctly.
Let's continue. Now I've got for example two RadTabItems (with the same HeaderTemplate) in one RadTabControl. The first RadTabItem is selected, the second one not. And now here it comes. When I click on the button (button in RadTabItem header) in the RadTabItem which is NOT selected, the event is not fired, only this specified RadTabItem becomes selected. So the click events are fired only when the RadTabItem is Selected.
The following behavior would be best for me: When I click on the button in header of arbitrary RadTabItem (selected or not) the click event of the button will be fired but the selection of the RadTabItems will NOT changed.
Is this scenario possible ? Or it would be great if at least the event of the buttons will be fired no matter the RadTabItem is selected or not.
Thank you a lot.
Stefan.
I'm using Q1 2010 for WPF.
I have this following simple sample:
<Window x:Class="sample.Window1" |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
xmlns:telNavigationControls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation" |
xmlns:telControlsControls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls" |
xmlns:sample="clr-namespace:sample" |
Title="Sample Window" Height="300" Width="300"> |
<Window.Resources> |
<Style x:Key="TelerikTabItemContainerStyle" TargetType="{x:Type telNavigationControls:RadTabItem}"> |
<Setter Property="HeaderTemplate"> |
<Setter.Value> |
<DataTemplate> |
<Button x:Name="closeButton" Content="Test Button" Height="25" sample:RoutedEventHelper.EnableRoutedClick="True"/> |
</DataTemplate> |
</Setter.Value> |
</Setter> |
</Style> |
</Window.Resources> |
<Grid> |
<telNavigationControls:RadTabControl x:Name="mainTabControl" ItemContainerStyle="{StaticResource TelerikTabItemContainerStyle}" > |
<telNavigationControls:RadTabItem > |
<telNavigationControls:RadTabItem.Content> |
<Button HorizontalAlignment="Center" VerticalAlignment="Center" Content="Test" IsDefault="True" /> |
</telNavigationControls:RadTabItem.Content> |
</telNavigationControls:RadTabItem> |
</telNavigationControls:RadTabControl> |
</Grid> |
</Window> |
As you can see, there is one RadTabControl with one RadTabItem. I've modified RadTabItem header through ItemContainerStyle. There is only one button in HeaderTemplate. I've used RoutedEventHandler class for allowing the button's click events to be catched.
Here is the code:
using System; |
using System.Collections.Generic; |
using System.Linq; |
using System.Text; |
using System.Windows; |
using System.Windows.Controls; |
using Telerik.Windows; |
using Telerik.Windows.Controls; |
namespace sample |
{ |
class RoutedEventHelper |
{ |
// TAB CLOSE BUTTON EVENT |
public static readonly RoutedEvent TabCloseButtonPressedEvent = EventManager.RegisterRoutedEvent( |
"TabCloseButtonPressed", |
RoutingStrategy.Bubble, |
typeof(RoutedEventHandler), |
typeof(RoutedEventHelper)); |
// DEPENDENCY PROPERTY FOR TAB ITEM HEADER BUTTON |
public static readonly DependencyProperty EnableRoutedClickProperty = DependencyProperty.RegisterAttached( |
"EnableRoutedClick", |
typeof(bool), |
typeof(RoutedEventHelper), |
new PropertyMetadata(OnEnableRoutedClickChanged)); |
// Add an attached property |
public static bool GetEnableRoutedClick(DependencyObject obj) |
{ |
return (bool)obj.GetValue(EnableRoutedClickProperty); |
} |
public static void SetEnableRoutedClick(DependencyObject obj, bool value) |
{ |
obj.SetValue(EnableRoutedClickProperty, value); |
} |
// TAB EVENT HANDLER |
private static void OnEnableRoutedClickChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
{ |
var button = sender as Button; |
if (button != null) |
button.Click += CloseButton_Click; |
} |
private static void CloseButton_Click(object sender, RoutedEventArgs e) |
{ |
var button = sender as Button; |
if (button == null) return; |
button.RaiseEvent(new RoutedEventArgs(TabCloseButtonPressedEvent, button)); |
} |
} |
} |
Everything works fine with one exception. If I put another Button as RadTabItem Content (as you can see in the above xaml example) and I set property of this button "IsDefault = true", the click events from the first button in RadTabItem header are not fired.
Is this behavior correct ?
I have also second question:
Imagine almost the same situation as in the previous example. I've RadTabItem with modified HeaderTemplate with one button in it. I've no buttons in the RadTabItem Content, so when I click on Button in my RadTabItem header, the click event is fired correctly.
Let's continue. Now I've got for example two RadTabItems (with the same HeaderTemplate) in one RadTabControl. The first RadTabItem is selected, the second one not. And now here it comes. When I click on the button (button in RadTabItem header) in the RadTabItem which is NOT selected, the event is not fired, only this specified RadTabItem becomes selected. So the click events are fired only when the RadTabItem is Selected.
The following behavior would be best for me: When I click on the button in header of arbitrary RadTabItem (selected or not) the click event of the button will be fired but the selection of the RadTabItems will NOT changed.
Is this scenario possible ? Or it would be great if at least the event of the buttons will be fired no matter the RadTabItem is selected or not.
Thank you a lot.
Stefan.