C# 如何在边框后绑定文本?

C# 如何在边框后绑定文本?,c#,wpf,xaml,C#,Wpf,Xaml,我使用3列。在第一列中,我放置了一个简单的边框,没有问题,但在我的第三列中,我希望在边框中有一个文本,然后(在右边)开始使用换行符。插入文本很容易,但我想使用绑定使其动态。请看下面我的代码 <Grid Grid.Row="1"> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="10"/>

我使用3列。在第一列中,我放置了一个简单的
边框
,没有问题,但在我的第三列中,我希望在
边框
中有一个文本,然后(在右边)开始使用换行符。插入文本很容易,但我想使用绑定使其动态。请看下面我的代码

<Grid Grid.Row="1">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto"/>
        <ColumnDefinition Width="10"/>
        <ColumnDefinition Width="Auto"/>
    </Grid.ColumnDefinitions>
    <Border Grid.Column="0" Background="Red" Height="15" Width="15" BorderBrush="Red" CornerRadius="100" Margin="5" Padding="5" VerticalAlignment="Top"/>
    <DockPanel Grid.Column="2" >
        <TextBlock TextWrapping="WrapWithOverflow"  Height="60" Width="450" LineHeight="20" LineStackingStrategy="BlockLineHeight" MaxWidth="{Binding ElementName=myWindowName, Path=ActualWidth}">
                <Border Background="Red" CornerRadius="10" Padding="10,0,10,0" Margin="0 -16 0 -5" Visibility="Visible" >
                    <TextBlock Text="Color and random text" Foreground="White" FontSize="12" FontWeight="Medium" />
                </Border>
                Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
            incididunt ut labore et dolore magna aliqua. 
        </TextBlock>
    </DockPanel>
</Grid>

Lorem ipsum dolor sit amet,是一位杰出的建筑设计师,也是一位临时建筑设计师
这是一个巨大的挑战。

将动态文本放入
运行元素中:

<TextBlock TextWrapping="WrapWithOverflow"  Height="60" Width="450" LineHeight="20" LineStackingStrategy="BlockLineHeight" 
        MaxWidth="{Binding ElementName=myWindowName, Path=ActualWidth}">
    <Border Background="Red" CornerRadius="10" Padding="10,0,10,0" Margin="0 -16 0 -5" Visibility="Visible" >
        <TextBlock Text="Color and random text" Foreground="White" FontSize="12" FontWeight="Medium" />
    </Border>
    <Run x:Name="run" Text="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. " />
</TextBlock>

是的,很好用。谢谢。
<Run Text="{Binding DynamicText, Mode=OneWay}" />