我有这样的用户控制(例如):
<UserControl
x:Class="Tester.UC"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Tester"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="400">
<Grid>
<TextBlock Name="Name" HorizontalAlignment="Left" Margin="10,10,0,0" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top" Height="79" Width="380" FontSize="50" TextAlignment="Center"/>
<Button Content="Button" HorizontalAlignment="Left" Margin="152,179,0,0" VerticalAlignment="Top"/>
<TextBox Name="LastName" HorizontalAlignment="Left" Margin="0,109,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="390" Height="65" TextAlignment="Center" FontSize="40"/>
</Grid>
要访问此控件,我必须使用名称,然后使用属性。像这样的东西。
UC uc = new UC();
uc.LastName.Text = "text";
有什么方法可以更快地访问它吗?我是说...
uc.LastName = "文本"