Example #1
0
        private void BtnEditPage_Click(object sender, RoutedEventArgs e)
        {
            // save index of item
            int mark = LvPage.SelectedIndex;
            // check if item is existed.
            if (mark != -1)
            {
                // get page from selected item.
                Page p = LvPage.SelectedItem as Page;

                // realize a window
                AddPageWindow window = new AddPageWindow();

                // add infomation for this window
                window.TxtName.Text = p.FileName;               // name
                window.TxtTitle.Text = p.PageTitle;             // page title
                // disable add button, show save button
                window.BtnAdd.Visibility = Visibility.Hidden;
                window.BtnSave.Visibility = Visibility.Visible;
                window.item = p;

                // show dialog
                window.ShowDialog();

                // update item
                WebSite.ListOfPage.RemoveAt(mark);
                WebSite.ListOfPage.Insert(mark, window.item);
            }

        }
Example #2
0
 private void BtnAddPage_Click(object sender, RoutedEventArgs e)
 {
     // show window for user can add infomation about his new page
     AddPageWindow window = new AddPageWindow();
     window.ShowDialog();
     // set selected item to new item
     LvPage.SelectedIndex = WebSite.ListOfPage.Count;            
 }