0
Das Bild, das ich von Code hinter erstellt habe, ist in meiner Visual-Struktur sichtbar, wird aber nicht auf dem Bildschirm gerendert, wenn ich meine App ausführen.Rendern Xaml Controls von C# -Code hinter in UWP
Dies ist mein Code Hinter
public MainPage()
{
this.InitializeComponent();
//Image that was created in Xaml
image.Source = new BitmapImage(new Uri("ms-appx:///testimage.jpg"));
//Image creation from C# code
Image image1 = new Image();
image1.Width = 200;
image1.Height = 200;
image1.Margin = new Thickness(50, 50, 0, 0);
image1.Source = new BitmapImage(new Uri("ms-appx:///download.jpg"));
//grid is the Grid name in Xaml
grid.Children.Add(image1);
}
Das ist mein XAML
<Page Name="HI"
x:Class="test1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:test1"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid x:Name="grid">
<Image x:Name="image" Visibility="Visible" HorizontalAlignment="Left" Height="200" Margin="10,200,0,0" VerticalAlignment="Top" Width="200"/>
</Grid>
Was ich hier fehlt?
Tag fehlt nur im Snippet. Mein Code hat Complete Xaml. –
Funktioniert gut für mich. Sind Sie sicher, dass 1) Bilder wirklich auf von Ihnen verwendeten Pfaden verfügbar sind? 2) Sie positionieren sie nicht außerhalb des sichtbaren Bereichs? – Konstantin
Ja, ich habe überprüft, Bild ist verfügbar im Pfad und sie auf dem Bildschirm Platz selbst, können Sie bitte Ihren Code teilen? –