Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6100279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:22:04+00:00 2026-05-23T13:22:04+00:00

I bind some values to WPF listview.I want to remove or hide some row

  • 0

I bind some values to WPF listview.I want to remove or hide some row when click or select in row.I m try to do this one as follow.

listview.Items.RemoveAt(listview.Items.IndexOf(listview.SelectedItem));

but it’s get exception.how to do this one? please help me……

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T13:22:05+00:00Added an answer on May 23, 2026 at 1:22 pm

    You can use MVVM pattern to achive it. You will need to create ObservableCollection, and then you can write command, wich will initialize with its collection, and when it should execute, it recieve object you need to delete via {Binding}. Its look like this:

    //View model
    public class FileGroupViewModel : ModelObject
    {
        private ObservableCollection<FileGroup> fileGroups;
        public FileGroupViewModel ( ObservableCollection<FileGroup> _initialFileGroup )
        {
            this.fileGroups = _initialFileGroup;
        }
    
        public ObservableCollection<FileGroup> FileGroups
        {
            get
            {
                return fileGroups;
            }
            set
            {
                fileGroups = value;                
            }
        }
    
        public ICommand DeleteFileGroup
        {
            get
            {
                return new RemoveItemCommand<FileGroup>(FileGroups);
            }
        }
    }
    

    RemoveItemCommand – is templated class which implements ICommand interface

    public class RemoveItemCommand<T> : ICommand
    {
        private ObservableCollection<T> _items;
        public RemoveItemCommand(ObservableCollection<T> items)
        {
            _items = items;
        }
        public void Execute(object parameter)
        {
            _items.Remove((T)parameter);
        }
        public bool CanExecute(object parameter)
        {
            return true;
        }
        public event EventHandler CanExecuteChanged;
    }
    

    then, your view will contain something like this^

    <DataTemplate>
         <Button Command="{StaticResource DeleteCommand}" CommandParameter="{Binding}" Text="{Binding}" />
    </DataTemplate>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have one hidden field and i want to bind it with two values
I am trying to bind some values to an ASP.NET Chart control. This is
I am using E4X to bind some values from xml in flex 3. There
Can I data bind two proporties values in a single textblock. For Example some
I'm building an application in C# using WPF. How can I bind to some
If I want to bind a collection to a some form of listing control
I have some code like this: [AcceptVerbs(HttpVerbs.Post)] public ActionResult Save([Bind(Prefix=)]Person person) { String s
I am struggling to bind some short cut keys to my WPF buttons. The
I'm trying to bind to some XML data from my WPF application. I've set
I'm playing around with WPF Binding and variables. Apparently one can only bind DependencyProperties.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.