我想像以下Xaml文档一样在代码上添加图像(cs文档)。
<Grid Margin="306,6,6,516">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Image Height="123" HorizontalAlignment="Left" Margin="6,6,0,0" Name="image1" Stretch="Fill" VerticalAlignment="Top" Width="132" Grid.Row="1" />
</Grid>
我这样做了。
Grid newGrid = new Grid();
Thickness thinkness = new Thickness(6,6,306,516);
newGrid.Margin = thinkness;
//RowDefinition rowDefin = new RowDefinition();
//rowDefin.Height = GridLength.Auto;
//newGrid.RowDefinitions.Add(rowDefin);
Image image = new Image();
image.Margin = thinkness;
image.Source = bitmap;
newGrid.Children.Add(image);
LayoutRoot.Children.Add(newGrid);
But nothing shows up on the page Any help?