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

Get focus to the user control in RadPanelBar

4 Answers 137 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
RJ
Top achievements
Rank 1
RJ asked on 20 Aug 2010, 12:59 PM

In the RadPanelBar, I added a user control that has a few text boxes. When I select the RadPanelBarItem, I’m unable to get the focus on the first textbox in the user control.  I have the  FocusManger.FocusedElement bound to the first text box in the user control.  How can I get the focus to the first textbox in the user control? Please advise.

Thanks
RJ

4 Answers, 1 is accepted

Sort by
0
Viktor Tsvetkov
Telerik team
answered on 25 Aug 2010, 12:40 PM
Hi RJ,

Could you please send me your sample project, so I will be able to better assist you?

Greetings,
Viktor Tsvetkov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
RJ
Top achievements
Rank 1
answered on 26 Aug 2010, 04:40 AM
Hi Viktor,

I can get the focus on the first textbox in the user control now. However, I can't  tab between the textboxes inside the user control. I would also like to use the up down arrows to move between the items. How can that be done. The sample is below.

Thanks
RJ
<Window xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"  x:Class="MainWindow"
     xmlns:local="clr-namespace:WpfApplication1" 
     Title="MainWindow" Height="450" Width="525" WindowStartupLocation="CenterScreen">
    <Grid>
        <local:UserControl2></local:UserControl2>
    </Grid>
</Window>
  
  
<UserControl x:Class="UserControl1"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             FocusManager.FocusedElement="{Binding ElementName=TextBox1}"
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid>
        <Grid Margin="6">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="85*" />
                <ColumnDefinition Width="203*" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="222*" />
                <RowDefinition Height="40*" />
            </Grid.RowDefinitions>
            <StackPanel Name="StackPanel1">
                <Label Height="28" Name="Label1" Width="Auto" HorizontalContentAlignment="Right" Margin="3">Order ID</Label>
                <Label Height="28" Name="Label2" Width="Auto" HorizontalContentAlignment="Right" Margin="3">Customer</Label>
                <Label Height="28" Name="Label3" Width="Auto" HorizontalContentAlignment="Right" Margin="3">Order Date</Label>
                <Label Height="28" Name="Label4" Width="Auto" HorizontalContentAlignment="Right" Margin="3">Ship Date</Label>
            </StackPanel>
            <StackPanel Grid.Column="1" Name="StackPanel2">
                <TextBox Height="28" Name="TextBox1" Width="Auto" Margin="3" />
                <TextBox Height="28" Name="TextBox2" Width="Auto" Margin="3" />
                <TextBox Height="28" Name="TextBox3" Width="Auto" Margin="3" />
                <TextBox Height="28" Name="TextBox4" Width="Auto" Margin="3" />
            </StackPanel>
        </Grid>
    </Grid>
</UserControl>
  
  
<UserControl x:Class="UserControl2"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" 
              xmlns:local="clr-namespace:WpfApplication1" 
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="400">
    <Grid>
        <telerik:RadDockPanel>
            <Border BorderThickness="3" BorderBrush="DarkGray" CornerRadius="5">
                <telerik:RadPanelBar Name="PB" VerticalContentAlignment="Top" 
                                     ExpandMode="Multiple" TabIndex="0" Selected="OnPanelBarEvent">
  
                    <telerik:RadPanelBarItem  Height="{Binding ElementName=UserControl1, Path=ActualHeight}"
                                        Header="First Item" IsExpanded="True" >
                        <StackPanel x:Name="SP" Width="{Binding ElementName=UserControl1, Path=ActualWidth}"
                                                    Height="{Binding ElementName=UserControl1, Path=ActualHeight}">
                            <!--User Control-->
                            <local:UserControl1 x:Name="UC"/>
                        </StackPanel>
                    </telerik:RadPanelBarItem>
  
                    <telerik:RadPanelBarItem  Height="{Binding ElementName=UserControl1, Path=ActualHeight}"
                                        Header="Second Item" IsExpanded="True" >
                        <StackPanel x:Name="SP1" Width="{Binding ElementName=UserControl1, Path=ActualWidth}"
                                                    Height="{Binding ElementName=UserControl1, Path=ActualHeight}">
                            <!--User Control-->
                            <local:UserControl1 x:Name="UC1"/>
                        </StackPanel>
                    </telerik:RadPanelBarItem>
                </telerik:RadPanelBar>
            </Border>
        </telerik:RadDockPanel>
    </Grid>
</UserControl>
  
  
Imports Telerik.Windows.Controls
Imports Telerik.Windows
  
Public Class UserControl2
    Public Sub New()
        InitializeComponent()
        AddHandler PB.Selected, AddressOf Me.OnPanelBarEvent
    End Sub
  
    Private Sub OnPanelBarEvent(ByVal sender As Object, ByVal e As RadRoutedEventArgs)
        Dim panelBarItem As RadPanelBarItem = TryCast(e.Source, RadPanelBarItem)
        If panelBarItem.Header IsNot Nothing Then
            If e.RoutedEvent.Name = "Selected" And panelBarItem.Header = "First Item" Then
                UC.TextBox1.Focus()
            Else
                If e.RoutedEvent.Name = "Selected" And panelBarItem.Header = "Second Item" Then
                    UC1.TextBox1.Focus()
                End If
            End If
        Else
        End If
  
    End Sub
End Class
0
Viktor Tsvetkov
Telerik team
answered on 26 Aug 2010, 12:41 PM
Hi RJ,

Could you please examine the attached sample project and tell me if it works for you?

Greetings,
Viktor Tsvetkov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
RJ
Top achievements
Rank 1
answered on 27 Aug 2010, 02:10 PM

Thank you Viktor, this is exactly what I was looking for. Appreciate your help.

RJ
Tags
PanelBar
Asked by
RJ
Top achievements
Rank 1
Answers by
Viktor Tsvetkov
Telerik team
RJ
Top achievements
Rank 1
Share this question
or