I created a UserControl
consisting of a Grid
which contains a single Image
-control.
<UserControl
x:Class="Album.AlbumPicture"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Album"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="400"
Width="200"
Height="200"
>
<Grid Width="200" Height="200">
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Image Name="AlbumPictureImage" Width="200" Height="200" Grid.Column="0" Grid.Row="0" />
</Grid>
</UserControl>
Now, I had a constructor that took an existing Image
(newly created from a Stream
) and assigned the Image
to my custom control's Image
AlbumPicture::AlbumPicture(Windows::UI::Xaml::Controls::Image^ Image){
InitializeComponent();
this->AlbumPictureImage = Image;
this->Height = 200;
this->Width = 200;
this->state = AlbumPictureState::SWIPE;
this->StartingPoint = Point(0,0);
}
In order to make sure my UserControl
was appended to the layout-container, I made the Background
of the Grid
white and it displayed fine. I also added the Image
directly to the layout-container and it was displayed properly.
Now, when I change the constructor to
AlbumPicture::AlbumPicture(Windows::UI::Xaml::Media::ImageSource^ Source){
InitializeComponent();
this->AlbumPictureImage->Source = Source;
this->Height = 200;
this->Width = 200;
this->state = AlbumPictureState::SWIPE;
this->StartingPoint = Point(0,0);
}
everything works fine and the Image
will be displayed. What is the catch here?
Image
-control-reference to theImage
of myUserControl
, it will be properly displayed, but nothing shows if I used my first approach. I just don't get why it does not get displayed...Container.Children
collection so it is included in the XAML visual tree?