-1

i have a ListView with following ItemTemplate

<ListView.ItemTemplate>
                <DataTemplate x:DataType="model:SubsceneDownloadModel">
                    <UserControl PointerEntered="ListViewSwipeContainer_PointerEntered" 
                                 PointerExited="ListViewSwipeContainer_PointerExited">
                        
                        <Grid AutomationProperties.Name="{x:Bind Name}">
                            <SwipeControl x:Name="ListViewSwipeContainer" >
                                <Grid VerticalAlignment="Center">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="auto"/>
                                        <RowDefinition Height="auto"/>
                                    </Grid.RowDefinitions>
                                    <TextBlock Text="{x:Bind Name}" 
                                               Margin="10,5,10,5" 
                                               FontSize="18" 
                                               HorizontalAlignment="Left" 
                                               VerticalAlignment="Center"/>

                                    <AppBarButton x:Name="DownloadHoverButton"
                                                  Margin="10,0,10,0"
                                                  HorizontalAlignment="Right"    
                                                  IsTabStop="False" 
                                                  Visibility="Collapsed"
                                                  Label="Download"
                                                  Icon="Download"
                                                  Click="DownloadHoverButton_Click"/>
                                   <ProgressRing x:Name="prgStatus"/>
                                </Grid>
                            </SwipeControl>
                        </Grid>
                    </UserControl>
                </DataTemplate>
            </ListView.ItemTemplate>

I want the value of the ProgressRing to change when I click on the AppBarButton but the problem is AppBarButton is not accessible from item template, so how can i access progressring from itemtemplate?

karma
  • 147
  • 7

1 Answers1

0

move your itemtemplate to a new usercontrol

<UserControl
    Name="subsceneView"
    x:Class="HandySub.UserControls.SubsceneUserControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d"
    PointerEntered="UserControl_PointerEntered"
    PointerExited="UserControl_PointerExited">
    
    <Grid>
       
        <SwipeControl x:Name="ListViewSwipeContainer" >
            <Grid AutomationProperties.Name="{x:Bind Name}">
                            <SwipeControl x:Name="ListViewSwipeContainer" >
                                <Grid VerticalAlignment="Center">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="auto"/>
                                        <RowDefinition Height="auto"/>
                                    </Grid.RowDefinitions>
                                    <TextBlock Text="{x:Bind Name}" 
                                               Margin="10,5,10,5" 
                                               FontSize="18" 
                                               HorizontalAlignment="Left" 
                                               VerticalAlignment="Center"/>

                                    <AppBarButton x:Name="DownloadHoverButton"
                                                  Margin="10,0,10,0"
                                                  HorizontalAlignment="Right"    
                                                  IsTabStop="False" 
                                                  Visibility="Collapsed"
                                                  Label="Download"
                                                  Icon="Download"
                                                  Click="DownloadHoverButton_Click"/>
                                   <ProgressRing x:Name="prgStatus"/>
                                </Grid>
                            </SwipeControl>
                        </Grid>
        </SwipeControl>
    </Grid>
</UserControl>

and in your listview

<ListView.ItemTemplate>
                <DataTemplate x:DataType="model:SubsceneDownloadModel">
                    <usercontrol:SubsceneUserControl/>
                </DataTemplate>
            </ListView.ItemTemplate>
Katana
  • 752
  • 4
  • 23