I added a new button to my pane header (a 'help' button) using the following link: http://www.telerik.com/help/silverlight/raddocking-how-to-add-buttons-to-the-pane-headers.html
I also created a custom routed ui command using the following link: http://www.telerik.com/help/silverlight/raddocking-how-to-add-menu-items-to-the-radpanes-menu.html
However, I had some trouble finding the RadPane containing the clicked RadButton in the pane header. I'm sure there is a much better or simpler way to find the current pane. Here is my solution, but could someone tell me what the proper method is?
Template attached to RadPane:
<DataTemplate x:Key="TitleTemplate">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<ContentPresenter Content="{Binding}"
Margin="0,0,10,0" />
<telerik:RadButton Style="{StaticResource helpButton}" Grid.Column="1" HorizontalAlignment="Right"
Command="common:HelpCommand.OpenHelpTooltipCommand" CommandParameter="{Binding}" CommandTarget="{Binding}">
<Image Style="{StaticResource imghelpButton}" />
</telerik:RadButton>
</Grid>
</DataTemplate>
Registered command:
CommandManager.RegisterClassCommandBinding(typeof(RadButton),
new CommandBinding(HelpCommand.OpenHelpTooltipCommand, HelpCommand.OnOpenHelpTooltip, HelpCommand.OnOpenHelpTooltipCanExecute));
Custom command:
public static class HelpCommand
{
private static RoutedUICommand openHelpTooltipCommand;
public static RoutedUICommand OpenHelpTooltipCommand
{
get
{
if (openHelpTooltipCommand == null)
{
openHelpTooltipCommand = new RoutedUICommand("Open help tooltip", "OpenHelpTooltipCommand", typeof(HelpCommand));
}
return openHelpTooltipCommand;
}
}
public static void OnOpenHelpTooltip(object sender, ExecutedRoutedEventArgs e)
{
var btn = e.OriginalSource as RadButton;
if (btn != null)
{
var parent = btn.GetVisualParent<Telerik.Windows.Controls.Docking.ToolWindow>();
if (parent != null)
{
var docking = parent.GetParentDocking();
if (docking != null)
{
foreach (var pane in docking.Panes)
{
if ((string)pane.Title == (string)btn.DataContext)
{
var control = pane.Content; //THERE MUST BE A BETTER WAY TO GET HERE!!!
}
}
}
}
}
}
public static void OnOpenHelpTooltipCanExecute(object sender, CanExecuteRoutedEventArgs e)
{
e.CanExecute = true;
}
}
I also created a custom routed ui command using the following link: http://www.telerik.com/help/silverlight/raddocking-how-to-add-menu-items-to-the-radpanes-menu.html
However, I had some trouble finding the RadPane containing the clicked RadButton in the pane header. I'm sure there is a much better or simpler way to find the current pane. Here is my solution, but could someone tell me what the proper method is?
Template attached to RadPane:
<DataTemplate x:Key="TitleTemplate">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<ContentPresenter Content="{Binding}"
Margin="0,0,10,0" />
<telerik:RadButton Style="{StaticResource helpButton}" Grid.Column="1" HorizontalAlignment="Right"
Command="common:HelpCommand.OpenHelpTooltipCommand" CommandParameter="{Binding}" CommandTarget="{Binding}">
<Image Style="{StaticResource imghelpButton}" />
</telerik:RadButton>
</Grid>
</DataTemplate>
Registered command:
CommandManager.RegisterClassCommandBinding(typeof(RadButton),
new CommandBinding(HelpCommand.OpenHelpTooltipCommand, HelpCommand.OnOpenHelpTooltip, HelpCommand.OnOpenHelpTooltipCanExecute));
Custom command:
public static class HelpCommand
{
private static RoutedUICommand openHelpTooltipCommand;
public static RoutedUICommand OpenHelpTooltipCommand
{
get
{
if (openHelpTooltipCommand == null)
{
openHelpTooltipCommand = new RoutedUICommand("Open help tooltip", "OpenHelpTooltipCommand", typeof(HelpCommand));
}
return openHelpTooltipCommand;
}
}
public static void OnOpenHelpTooltip(object sender, ExecutedRoutedEventArgs e)
{
var btn = e.OriginalSource as RadButton;
if (btn != null)
{
var parent = btn.GetVisualParent<Telerik.Windows.Controls.Docking.ToolWindow>();
if (parent != null)
{
var docking = parent.GetParentDocking();
if (docking != null)
{
foreach (var pane in docking.Panes)
{
if ((string)pane.Title == (string)btn.DataContext)
{
var control = pane.Content; //THERE MUST BE A BETTER WAY TO GET HERE!!!
}
}
}
}
}
}
public static void OnOpenHelpTooltipCanExecute(object sender, CanExecuteRoutedEventArgs e)
{
e.CanExecute = true;
}
}