-1

TextBlock を含む UserControl を作成しましたが、この UserControl を使用した MainPage からこの UserControl のテキストを変更できないという問題があります。

Plz は、基本的に Windows Phone の開発者である Metro スタイル アプリの初心者です。以下のユーザーコントロールのソースを確認してください。

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

この UserControl が使用されているページから「edit」という名前のテキストブロックにアクセスできません。

4

3 に答える 3

0

ユーザーコントロールのコントロールは公開されていないため、これはまったく正常です。これらのコントロールを利用できるようにするには、ユーザーコントロールでパブリックプロパティを定義する必要があります...

于 2013-04-23T12:43:07.880 に答える
0

Grid.ColumnDefinitions とGrid.RowDefinitionsが抜けているようです

<Grid x:Name="grid_amorti" ...>  
    <Grid.Background>
         <ImageBrush ImageSource="Image/inside_menu_normal.png"/>            
    </Grid.Background>
    <Grid.ColumnDefintion>

    </Grid.ColumnDefinition>
    <Grid.RowDefiniton>

    </Grid.RowDefinition>
</Grid>

だから、あなたは実際にそれらを置き忘れています...

于 2013-04-23T12:44:21.900 に答える
0

通常、TextBlock は UserControl 内のプライベート フィールドです。たとえば、次の手法を使用して、変更できるようにするプロパティを再公開する必要があります: http://www.geekchamp.com/tips/how-to-expose-properties-of-a-user-control- Windows Phone 内

于 2013-04-23T12:44:34.387 に答える