开发者

how to Set property of user control to its child controls in silverlight.?

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="In开发者_JAVA技巧putTextBox" 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 ???


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; }

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜