Data binding RRS feed

  • Question

  • Hi!

    I am newbie in Windows app development, so an easy question... How can i get item Uri in Play_Button_Click method, when AppBarButton is clicked?


                AutomationProperties.Name="Grouped Items"
                ItemsSource="{Binding Source={StaticResource groupedItemsViewSource}}"
                        <Grid HorizontalAlignment="Left" Width="250" Height="250">
                            <Border Background="{ThemeResource ListViewItemPlaceholderBackgroundThemeBrush}">
                                <Image Source="{Binding ImagePath}" Stretch="UniformToFill" AutomationProperties.Name="{Binding Title}"/>
                            <StackPanel VerticalAlignment="Bottom" Orientation="Horizontal" Background="{ThemeResource ListViewItemOverlayBackgroundThemeBrush}">
                                <TextBlock Text="{Binding Title}" Foreground="{ThemeResource ListViewItemOverlayForegroundThemeBrush}" Style="{StaticResource TitleTextBlockStyle}" Height="90" Width="150" Margin="15,0,0,0"/>
                                <AppBarButton Icon="Play" Height="100" Width="100" Click="Play_Button_Click"/>
                        <ItemsWrapGrid GroupPadding="0,0,70,0"/>


    void iRadio::GroupedItemsPage::Play_Button_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) { (void) sender; // Unused parameter auto uri = safe_cast<Data::SampleDataItem^>(e->OriginalSource)->Uri; }

    Of course now i get an exception.

    Wednesday, May 7, 2014 8:57 PM


  • Hi,

    I do not quite understand your question. What's meaning about Uri? where the Uri contain in. Do you mean the Uri contain in the groupedItemsViewSource item. If so, you can define a index value in the groupedItemsViewSource item and bind the AppBarButton's Tag property to the index. Then in the Button_Click event you can get the tag vaule and then use the value to check which item you click in the groupedItemsViewSource and then get the Uri Value. You can see the link below:


    And for data binding i recommand you can refer to the links:


    XAML data binding sample

    Best Wishes!

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey. Thanks<br/> MSDN Community Support<br/> <br/> Please remember to &quot;Mark as Answer&quot; the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Thursday, May 8, 2014 2:54 AM