1

変数を RichTextBlock の Text プロパティにバインドしようとしていますが、コンテンツが表示されません。RichTextBlock は、共通フォルダーにある RichTextColumns 要素内にあります。

私のXamlコード:-

<Page
x:Class="Test_Menu.TopicDetailsPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Test_Menu"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:common="using:Test_Menu.Common"
mc:Ignorable="d">

<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
    <!-- Content is allowed to flow across as many columns as needed -->
    <common:RichTextColumns x:Name="richTextColumns" >
        <RichTextBlock x:Name="richTextBlock" Width="300" Height="700" Style="{StaticResource ItemRichTextStyle}" IsTextSelectionEnabled="False" >
            <Paragraph>
                <Run FontWeight="Normal" Text="{Binding sTitle}" Foreground="White" />
            </Paragraph>
        </RichTextBlock>

        <!-- Additional columns are created from this template -->
        <common:RichTextColumns.ColumnTemplate>
            <DataTemplate>
                <RichTextBlockOverflow Width="450" Margin="80,0,0,0">
                    <RichTextBlockOverflow.RenderTransform>
                        <TranslateTransform X="-1" Y="4"/>
                    </RichTextBlockOverflow.RenderTransform>
                </RichTextBlockOverflow>
            </DataTemplate>
        </common:RichTextColumns.ColumnTemplate>
    </common:RichTextColumns>

</Grid>

私の背後にあるコード -

namespace Test_Menu

{ パブリック シール部分クラス TopicDetailsPage : ページ { パブリック文字列 sTitle { get; 設定; }

    public TopicDetailsPage()
    {
        sTitle = "Test Text";
        this.InitializeComponent();
        richTextBlock.DataContext = sTitle; //name of richTextBlock

    }

    protected override void OnNavigatedTo(NavigationEventArgs e)
    {
    }
}

}

アウトは空白のままです。どんな助けでも大歓迎です。

4

0 に答える 0