locked
How to remove the tick mark on the selected list item in a dynamically created listview?

    Question

  • HI ,

    I am creating a listview programmatically when required. Using 

       ListView navigationList = new ListView();
                navigationList.Name = "RepositoryNavigationList";

    How can i override the style to remove the tick mark when an item in the list view is selected?

    Thanks

    Monday, September 15, 2014 4:08 AM

Answers

  • Hi VDNS,

    To modify the ListViewItem styles and templates can remove the tick mark on the selected item.

    After you remove the following code from template:

                                        <Grid x:Name="SelectedCheckMark" Opacity="0" Height="40" Width="40">
                                            <Path x:Name="SelectedEarmark" Data="M0,0 L40,0 L40,40 z"  Fill="{ThemeResource ListViewItemSelectedBackgroundThemeBrush}" Stretch="Fill"/>
                                            <Path Data="F1 M133.1,17.9 L137.2,13.2 L144.6,19.6 L156.4,5.8 L161.2,9.9 L145.6,28.4 z" Fill="{ThemeResource ListViewItemCheckThemeBrush}" Height="13" Stretch="Fill" Width="15" HorizontalAlignment="Right" Margin="0,5.5,5.5,0" VerticalAlignment="Top" FlowDirection="LeftToRight"/>
                                        </Grid>

    Assign a name for the template, and apply it to the listview programmatically. For instance I apply my button style to a button via code.

    button.Style = (Style)Application.Current.Resources["myButtonStyle"];

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" 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.

    Tuesday, September 16, 2014 5:09 AM
    Moderator

All replies

  • listBox.Items.RemoveAt(listBox.SelectedIndex);

    Here is a piece of code paste it into the selection changed event and now you can remove the selected index. If you found it useful please mark as answer.

    Muhammad Asad.

    Monday, September 15, 2014 7:21 AM
  • Hello Asad,

    Thanks for your help.

    I do not want to the remove the selected item.

    But I want to remove just the tick mark that appears when the item is selected.

    Monday, September 15, 2014 10:12 AM
  • Can you paste the xaml here or C# code where you are doing this?

    Muhammad Asad

    Microsoft Student Partner.

    Monday, September 15, 2014 5:19 PM
  • Hi

    Grid view and list view has selector item  property which is enabled true and it showed default blue colour tick mark.

    if you declare this property false then it will remove that selected tick mark from item .

    To learn more about this visit following link

    http://code.msdn.microsoft.com/windowsapps/CSWindowsStoreAppDisableIte-716be3f2

    Thanks

    if you find this  helpful , then mark this answer.


    Monday, September 15, 2014 5:47 PM
  • Hi, you can set SelectionMode property to "None", for disable selection (if you want it) or override default style of ListView and set it when you create new instance.


    Regards, Nikita.


    Monday, September 15, 2014 5:53 PM
  • Hi VDNS,

    To modify the ListViewItem styles and templates can remove the tick mark on the selected item.

    After you remove the following code from template:

                                        <Grid x:Name="SelectedCheckMark" Opacity="0" Height="40" Width="40">
                                            <Path x:Name="SelectedEarmark" Data="M0,0 L40,0 L40,40 z"  Fill="{ThemeResource ListViewItemSelectedBackgroundThemeBrush}" Stretch="Fill"/>
                                            <Path Data="F1 M133.1,17.9 L137.2,13.2 L144.6,19.6 L156.4,5.8 L161.2,9.9 L145.6,28.4 z" Fill="{ThemeResource ListViewItemCheckThemeBrush}" Height="13" Stretch="Fill" Width="15" HorizontalAlignment="Right" Margin="0,5.5,5.5,0" VerticalAlignment="Top" FlowDirection="LeftToRight"/>
                                        </Grid>

    Assign a name for the template, and apply it to the listview programmatically. For instance I apply my button style to a button via code.

    button.Style = (Style)Application.Current.Resources["myButtonStyle"];

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" 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.

    Tuesday, September 16, 2014 5:09 AM
    Moderator