我创建了一个带有TextBlock的UserControl,问题是我无法从使用此用户控件的MainPage中更改此UserControl的文本。无法访问UserControl中的子元素
Plz帮助新来Metro风格应用程序基本上是Windows手机开发者。检查下面的usercontrol的来源。
<UserControl
x:Class="Version1forMainMenu.MyUserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Version1forMainMenu"
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" x:Name="MyUserControl1">
<Grid x:Name="grid_amorti" PointerEntered="gride_quickestimate_PointerEntered" PointerExited="gride_quickestimate_PointerExited" PointerPressed="gride_quickestimate_PointerPressed" PointerReleased="gride_quickestimate_PointerReleased" Tapped="gride_quickestimate_Tapped">
<Grid.Background>
<ImageBrush ImageSource="Image/inside_menu_normal.png"/>
</Grid.Background>
<TextBlock Grid.Row="1" Grid.Column="2" Grid.ColumnSpan="3" x:Name="edit" Text="" FontSize="30" FontWeight="Bold" VerticalAlignment="Center" FontFamily="Global User Interface" Margin="10,112,29,111" ></TextBlock>
<Image Grid.Row="1" x:Name="img" Grid.Column="5" Source="Image/small_arrow.png" />
</Grid>
我无法从在使用此用户控件的网页访问名为“编辑”的文本块。
为什么不使用[x:FieldModifier指令](http://msdn.microsoft.com/zh-cn/库/ aa970905.aspx)? – 2013-04-23 17:50:52
这不会很干净,控件的名称不是外部元素应该知道的东西。国际海事组织最好的办法就是暴露有用的属性,就像正常的控制一样。另外,它允许您在声明和使用UserControl时数据绑定这些属性。 – 2013-04-24 07:44:20