我正在尝试创建一个Border
dynamicaly并尝试在其中添加Image
。这可能吗?
C#:
private void AddToHistory()
{
HistoryBorder.Visibility = System.Windows.Visibility.Visible;
Border Br = new Border();
Br.BorderBrush = Brushes.Black;
Br.BorderThickness = new Thickness(2) ;
Image tem = new Image();
tem.Source = image1.Source;
Br.Content = tem; // ?? Error here.
StackHistory.Children.Add(Br);
}
XAML:
<Grid Grid.Column="2" x:Name="History">
<ScrollViewer>
<Border x:Name="HistoryBorder" BorderThickness="4" CornerRadius="1" BorderBrush="#FFF2C683" Visibility="Hidden">
<StackPanel x:Name="StackHistory" HorizontalAlignment="Left" VerticalAlignment="Top" >
</StackPanel>
</Border>
</ScrollViewer>
</Grid>