2

I have this list view on a windows store app project

<ListView ItemsSource="{Binding Attachments}"  IsItemClickEnabled="False" SelectionMode="None">
                                <ListView.ItemTemplate>
                                    <DataTemplate >
                                        <Grid Width="280" Height="50" Margin="85,0,0,0">
                                            <Grid.RowDefinitions>
                                                <RowDefinition Height="*"/>
                                                <RowDefinition Height="5" />
                                            </Grid.RowDefinitions>
                                            <RadioButton GroupName="meetingFiles" Content="TESTE" Style="{StaticResource RadioButtonStyle1}"></RadioButton>
                                            <TextBlock Text="1" HorizontalAlignment="Right"></TextBlock>
                                            <Grid x:Name="whiteLine" Grid.Row="1" Width="270" Height="1" Background="White" HorizontalAlignment="Center" />
                                        </Grid>
                                    </DataTemplate>
                                </ListView.ItemTemplate>
                            </ListView>

i want that my last item on the listview dont show the grid named whiteLine how can i do that? or is it impossible?

Thought
  • 5,326
  • 7
  • 33
  • 69
  • 1
    possible duplicate of [Use different template for last item in a WPF itemscontrol](http://stackoverflow.com/questions/7767097/use-different-template-for-last-item-in-a-wpf-itemscontrol) – Brian Gradin Aug 11 '15 at 16:57
  • 1
    Thats WPF, im working on winrt, i dont think it has – Thought Aug 11 '15 at 17:13

2 Answers2

2

An alternative solution would be to add a Listview.footer as so:

<ListView>
     <!-- Your Listview ItemTemplate /-->
     <ListView.Footer>
           <Grid Width="280" Height="50" Margin="85,0,0,0">
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="5" />
           </Grid.RowDefinitions>
           <RadioButton GroupName="meetingFiles" Content="TESTE" Style="{StaticResource RadioButtonStyle1}"></RadioButton>
           <TextBlock Text="1" HorizontalAlignment="Right"></TextBlock>
     </ListView.Footer>
</ListView>

This isn't really changing the last item, it is adding an element that is always at the bottom of the ListView, and looks the same as your items. This will give the user the impression that it is part of the listview, and you will keep your code simple.

user2950509
  • 1,018
  • 2
  • 14
  • 37
0

Either

<ListView ItemTemplateSelector="..."/> 

Or binding the Grid's Visibility would do the trick. But you would need some type of flag variable in your Model such that you can use that to determine if it is the last one in the list.

I used the above solution to alternate the background color of each item in the ListView, with my Model containing a RowID as well.

Chubosaurus Software
  • 8,133
  • 2
  • 20
  • 26