Friday, June 8, 2012

Add UI element in Metro Style application using C++ code

To add UI element in Metro Style application dynamically using C++ code, instead of XAML:

Modify XAML to have a name in the root content, the <Grid> in this exercise:
    <Grid x:Name="root" Background="{StaticResource ApplicationPageBackgroundThemeBrush}">

    </Grid>


Modify the C++ code behind:
MainPage::MainPage()
{
 InitializeComponent();
 
 Uri^ imageUri = ref new Uri("http://goo.gl/fHDLv");
 BitmapImage^ bitmapImage = ref new BitmapImage(imageUri);
 Image^ image = ref new Image();
 image->Source = bitmapImage;
 image->Width = 100;
 image->Height = 53;

 root->Children->Append(image);


}


Add UI element in Metro Style application using C++ code


No comments:

Post a Comment