/// <summary>
        /// Refreshes the list of directories and files.
        /// </summary>
        public void RefreshList()
        {
            _listView.Clear();

            try
            {
                // Get the string list of directories for the current
                // directory.
                string[] dirs = Directory.GetDirectories(Directory.GetCurrentDirectory());

                // If this is not the root directory of the volume, add a
                // ".." entry.  In this demo, the root volume is named
                // "\\ROOT".
                if (Directory.GetCurrentDirectory() != "\\")
                {
                    ListViewItem item = new ListViewItem();
                    item.AddSubItem("[..]");
                    _listView.AddItem(item);
                }

                // Add each directory name to the list view.
                for (int i = 0; i < dirs.Length; i++)
                {
                    ListViewItem item = new ListViewItem();
                    item.AddSubItem("[" + dirs[i] + "]");
                    _listView.AddItem(item);
                }

                // Get the string list of files for the current directory.
                string[] files = Directory.GetFiles(Directory.GetCurrentDirectory());

                // Add each file name and its information to the list view.
                for (int i = 0; i < files.Length; i++)
                {
                    // Get information about the file.
                    FileInfo info = new FileInfo(files[i]);

                    // Add the name, length, and creation date.
                    ListViewItem item = new ListViewItem();
                    item.AddSubItem(files[i]);
                    item.AddSubItem(info.Length.ToString());
                    item.AddSubItem(info.CreationTime.ToString("d"));
                    _listView.AddItem(item);
                }
            }
            catch (Exception ex)
            {
                Debug.Print(ex.ToString());
            }
        }
        public void RemoveItem(ListViewItem listViewItem)
        {
            if (listViewItem == SelectedItem)
            {
                SelectedItem = null;
            }

            Items.Remove(listViewItem);
        }
        /// <summary>
        /// Handles the OnTouchDown event.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnTouchDown(TouchEventArgs e)
        {
            int x = 0;
            int y = 0;

            e.GetPosition(this, 0, out x, out y);

            try
            {
                // Figure out which section of the screen was clicked.
                if (y <= _columnHeaderHeight)
                {
                    // Ignore clicks on column headers.
                }
                else if (y >= (Height - _scrollbarDimension))
                {
                    // The horizontal scrollbar was clicked.
                    OnHorizontalScrollStylusDown(x);
                }
                else if (x >= (Width - _scrollbarDimension))
                {
                    // The vertical scrollbar was clicked.
                    OnVerticalScrollStylusDown(y);
                }
                else
                {
                    // Main section; an item was clicked.

                    int previousIndex = Items.IndexOf(SelectedItem);

                    // Calculate which item was clicked.
                    int index = ((y - _columnHeaderHeight) + _verticalScroll) / _itemHeight;

                    // No item is selected, so select this one.
                    if ((index >= 0) && (index < Items.Count))
                    {
                        SelectedItem = (ListViewItem)Items[index];
                    }
                    else
                    {
                        SelectedItem = null;
                        index = -1;
                    }

                    // Refresh the list view.
                    Invalidate();

                    if (SelectionChanged != null)
                    {
                        SelectionChanged(this, new SelectionChangedEventArgs(previousIndex, index));
                    }
                }
            }
            catch (IOException ex)
            {
                Debug.Print(ex.ToString());
            }
        }
 /// <summary>
 /// Adds an item to the list view, given a full list view item.
 /// </summary>
 /// <param name="listViewItem">The item to add to the list view.
 /// </param>
 public void AddItem(ListViewItem listViewItem)
 {
     Items.Add(listViewItem);
 }