我創建了一個帶有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