.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Not understanding how to RemoveAt() in ObservableCollection ListView

Posted By:      Posted Date: October 28, 2010    Points: 0   Category :WPF

I've created an MRU listView with buttons in WPF and I know how to determine which itme in the listview was clicked but I'm having trouble removing the item from the listview using remove at.

I want to replicate the listview used word 2010.

I'm writing key's to the registry to store Name "Item1" etc. with the Data "D:\\Somefile.txt"

I'll add "[true]" etc. as a pin state later.

I need to sync my registry with my List and I can read the list in fine and display the buttons.

I just need to be able to update the registry and list state when a new item is added. 

Previously I removed the key if it existed using a string compare in c#, but now I'm using databinding and moving through the Observable Collection and don't understand how since I have two items in my collection, MRUFileName and MRUPath, 

My collection is setup as so:

First I've declared my collection

ObservableCollection<MRUClass> _filename = new ObservableCollection<MRUClass>();    // MRU Collection
then I setup my Getter/Setters in my class:

More Related Resource Links

Listview Item RemoveAt


Hi There,

I'm trying to delete a item from the listview.

I can delete the item from the database ok, but the listview item does not get removed, I could do a Response.Redirect to redisply the page but this is overkill?

Below is my code:

 Private Sub ListView1_ItemDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ListViewDeleteEventArgs) Handles ListView1.ItemDeleting

  Dim key As String = Me.ListView1.DataKeys(e.ItemIndex).Value.ToString()

    'Dim mDbase As New SQL40.Database.SQL.SQL(<Sever>, <Database>, "", "", True)
    ' mDbase.Open()
    ' mDbase.Record.Delete("DELETE FROM TBLResults WHERE ID=" & key)
    ' mDbase.Close()
 End Sub


Truly Understanding View State

This article provides a detailed understanding of the ViewState.

Using ASP.NET 3.5's ListView and DataPager Controls: Displaying Data with the ListView

Prior to ASP.NET 3.5, developers who needed to display a set of records could choose between the GridView, DataList, and Repeater controls. The GridView provides rich data features, but has a very boxy layout; the DataList and Repeater allow for a more flexible layout, but lack the "point and click" data features found in the GridView, DetailsView, and FormView controls. The ListView bridges the gap between layout flexibility and built-in data features.

This article, the first in a series of articles on the ListView and DataPager controls, looks at the ListView's many available templates and illustrates how to display data. Read on to learn more!

WPF Tutorial - Using The ListView, Part 1

Many of the controls in WPF have a downright dizzying array of capabilities and features, due in large part to the composibility of all the components. The ListView control is a great example of this - the possibilities are almost endless. This series of tutorials on the ListView will hopefully make the space of possible options seem not quite as daunting

How to listen to events within a listview



I've got a listview and I've put a button control in one of the columns, I'm trying to figure out how I have listen to the button click within a certain row, but can't see the button in the dropdown for the IDs I can generate events for.

I'd like to get the primary key of the row that's been clicked on and then run a sql statement against it.

Any help would be appreciated.

ListView DataPager with SQL-Statements that already return only paged data.



As far as I understand the ListView-Control and the DataPager-Control, they work like this: The ListView gets its datarows from its data source, then the DataPager causes the ListView to display only a subset of those rows.

So what, when I want to use custom databinding for the ListView, that *already* gets the certain subset from SQL-Server (for better performance). Can I and how can I use the DataPager then?

Thanx, S.

CLR Inside Out: Understanding The CLR Binder


In this article, we cover some of the best practices for assembly binding and loading using the CLR.

Aarthi Ramamurthy and Mark Miller

MSDN Magazine May 2009

Advanced Basics: The ObservableCollection Class


Ken Getz shows how the CollectionChanged event lets you reflect changes to your underlying data source in your bound data controls.

Ken Getz

MSDN Magazine December 2008

Access Control: Understanding Windows File And Registry Permissions


Understanding the ACLs that govern permissions and rights before an operation is allowed to proceed is critical to enhancing security.

John R. Michener

MSDN Magazine November 2008

Advanced WPF: Understanding Routed Events And Commands In WPF


See how routed events and routed commands in Windows Presentation Foundation form the basis for communication between the parts of your UI.

Brian Noyes

MSDN Magazine September 2008

Cutting Edge: ListView Tips and Tricks


This month, use nested ListView controls to create hierarchical views of data and extend the eventing model of the ListView by deriving a custom ListView class.

Dino Esposito

MSDN Magazine April 2008

CLR Debugging: Improve Your Understanding of .NET Internals by Building a Debugger for Managed Code


With the release of .NET, the Microsoft scripting strategy has evolved. Script engines can now compile or interpret code for the Microsoft common language runtime (CLR) instead of integrating debugging capabilities directly into apps through Active Scripting. With that change comes a new set of published services for including debugging functionality in a custom host application. You'll see how to use the debugging services published in the .NET Framework to create a full-featured CLR debugger that allows you to set breakpoints, view call stacks, browse variables, view processes, enumerate threads, and perform other important debugging tasks.

Mike Pellegrino

MSDN Magazine November 2002

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend