Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在矩形内放置文本块_C#_Wpf_Xaml_Textblock - Fatal编程技术网

C# 如何在矩形内放置文本块

C# 如何在矩形内放置文本块,c#,wpf,xaml,textblock,C#,Wpf,Xaml,Textblock,我发现了这一点,它解释了如何在XAML中排列网格中的矩形集合: <Grid... > <Rectangle Grid.Column="0" Grid.Row="0" Stroke="Blue" Fill="Transparent" /> <TextBlock Grid.Column="0" Grid.Row="

我发现了这一点,它解释了如何在XAML中排列网格中的矩形集合:

<Grid... >
    <Rectangle Grid.Column="0"
               Grid.Row="0"  
               Stroke="Blue"
               Fill="Transparent" />
        <TextBlock Grid.Column="0" 
                   Grid.Row="0"
                   Text="(0,0)" />
    </Rectangle>
    ...
</Grid>

...

现在我尝试在C#中做同样的事情,我发现矩形没有内容属性。那么如何将文本块添加到矩形中呢?

您可以使用
边框
而不是
矩形
,因为
边框.内容
确实存在


您不需要设置
矩形.Stroke
矩形.Fill
您可以设置
边框.BorderBrush
边框.Background

您可以使用
边框
而不是
矩形
,因为
边框.Content
确实存在

您可以设置
Border.BorderBrush
Border.Background
而不是设置
Rectangle.Stroke
Rectangle.Fill