0

这是我的 C#,它似乎可以很好地加载 Xaml,所有子项以及它们包含的数据都在 R1C3Viewbox 中。但是屏幕上什么也没有显示。

ParserContext context = new ParserContext();
context.XmlnsDictionary.Add("", 
"http://schemas.microsoft.com/winfx/2006/xaml/presentation");
context.XmlnsDictionary.Add("x", 
"http://schemas.microsoft.com/winfx/2006/xaml");

using (FileStream fs = new FileStream("R1C3Viewbox.xaml", FileMode.Open))
    {
      R1C3Viewbox = (Viewbox)XamlReader.Load(fs, context);
    }

xaml 文件包含:

<Viewbox Name="R1C3Viewbox" Grid.Row="1" Grid.Column="6" Grid.ColumnSpan="1" 
Grid.RowSpan="1">
  <Border Name="R1C3Border" BorderBrush="Black" CornerRadius="3" 
  BorderThickness="1" Background="#FFFFC602" Height="40" Width="40" 
  Margin="3,3,0,0">
    <Grid Name="R1C3Grid">
      <TextBlock Name="R1C3TextBlock1" FontFamily="Arial" FontSize="10" 
       FontWeight="Bold" Text="RAPID" Foreground="Black" 
       Margin="4,12,0,15"/>
      <TextBlock Name="R1C3TextBlock2" FontFamily="Arial" FontSize="10" 
      FontWeight="Bold" Text="OVER" Foreground="Black" Margin="5,23,5,3"/>
      <Polygon Name="R1C3LED" Points="0,0 15,0 0,15" Stroke="#FFED1C24" 
       StrokeThickness="1"> 
       <Polygon.Fill> <RadialGradientBrush> <GradientStop Color="White" 
       Offset="2.5"/> <GradientStop Color="Black"/> </RadialGradientBrush> 
       </Polygon.Fill>
       </Polygon>
       <Button Name="R1C3Button" Background="Transparent" 
        BorderBrush="Transparent"></Button>
      </Grid>
     </Border>
   </Viewbox>

任何想法将不胜感激。

4

0 回答 0