0

I had a rich textbox like this:

      <RichTextBox x:Name="richtextbox">
            <RichTextBox.Template>
                <ControlTemplate>
                    <StackPanel Orientation="Horizontal">
                        <HyperlinkButton  x:Name="txtnam" HorizontalAlignment="Left" VerticalAlignment="Center" Width="3" />
                        <TextBlock x:Name="txttextblock" Width="452"/>
                    </StackPanel>
                </ControlTemplate>
            </RichTextBox.Template>
        </RichTextBox>

Now i want to insert a text in textblock using button click event.If textblock is out of richtextbox we can access like this.txttextblock.text ="content". But how access this textblock now in button click.Can any one please help me to find the solution.

4

1 回答 1

0

您可以使用“FindName”方法来查找子元素。

((TextBlock)richtextbox.FindName("txttextblock")).Width

输出:452

于 2013-07-22T18:58:56.940 回答