1
votes

I have created a user control. XAML code is as follows.

<UserControl x:Class="UserControlsLibrary.NumericUpDown1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="25" d:DesignWidth="70">
<StackPanel Orientation="Horizontal" VerticalAlignment="Top" >
    <TextBox x:Name="InputTextBox" Grid.Row="0" Grid.Column="0" Grid.RowSpan="1"
             />
</StackPanel>

This is my Usercontrol's implementation in MainPage.xaml XAML code as follows

<UserControl x:Class="UserControlsLibrary.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:DependencyPropertyBinding"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<StackPanel Height="350" Width="400" Orientation="Horizontal">
    <userControl:NumericUpDown1 x:Name="myusercontrol" TabIndex="34""/>
    <Button Content="Show" Height="40" Width="150" Click="Button_Click" >         </Button>
</StackPanel>

I want to set TabIndex property of UserControl from MainPage.xaml to the TabIndex property of the UserControl's TextBox's TabIndex property.

How do i set it ???

1
Answer : In the GotFocus event of TextBox I assingned user control TabIndex to TextBox tabIndex and it works. InputTextBox is control name inside user control. private void InputTextBox_GotFocus(object sender, RoutedEventArgs e) { this.InputTextBox.TabIndex = this.TabIndex; }pramod choudhari
Please don't use comments to place answers and certainly don't attempt to include code in comments. Its ok for you to answer your own question for the benefit of others that find your question.AnthonyWJones

1 Answers

0
votes

Answer : In the GotFocus event of TextBox I assingned user control TabIndex to TextBox tabIndex and it works. InputTextBox is control name inside user control. private void InputTextBox_GotFocus(object sender, RoutedEventArgs e) { this.InputTextBox.TabIndex = this.TabIndex; }