Im creating a visual list in my app, what i want to do is implement a checklist function where a user can cross out an item on the list however it seems that this cant be achieved with text decorations. So i want to draw it manually.
Im using a ObservableCollection and a ListBox to display the collection.
How exactly would i go about drawing a line through a specific element in a listBox?? I can add and remove items so far.
public MainPage()
{
InitializeComponent();
ApplicationBar = new ApplicationBar();
ApplicationBar.Mode = ApplicationBarMode.Default;
ApplicationBar.Opacity = 1.0;
ApplicationBar.IsVisible = true;
ApplicationBar.IsMenuEnabled = true;
ApplicationBarIconButton bAdd = new ApplicationBarIconButton();
bAdd.IconUri = new Uri("/Images/appbar.add.rest.png", UriKind.Relative);
bAdd.Text = "Add Item";
ApplicationBar.Buttons.Add(bAdd);
bAdd.Click += new EventHandler(bAdd_Click);
ApplicationBarIconButton bDel = new ApplicationBarIconButton();
bDel.IconUri = new Uri("/Images/appbar.minus.rest.png", UriKind.Relative);
bDel.Text = "Remove Item";
ApplicationBar.Buttons.Add(bDel);
bDel.Click += new EventHandler(bDel_Click);
ApplicationBarIconButton bClear = new ApplicationBarIconButton();
bClear.IconUri = new Uri("/Images/appbar.delete.rest.png", UriKind.Relative);
bClear.Text = "Clear List";
ApplicationBar.Buttons.Add(bClear);
bClear.Click += new EventHandler(bClear_Click);
list = new ObservableCollection<string>();
listBox1.ItemsSource = list;
}
private void bDel_Click(object sender, EventArgs e)
{
try
{
list.RemoveAt(listBox1.SelectedIndex);
}
catch (ArgumentOutOfRangeException ex)
{
MessageBox.Show("Error: Please select a valid item to delete!");
}
}
private void bClear_Click(object sender, EventArgs e)
{
list.Clear();
MessageBox.Show("list Cleared");
}
void button1_Click(object sender, RoutedEventArgs e)
{
try
{
String item = b1.Text;
if (item.Length <= 0)
{
throw new System.ArgumentException("Error: Please enter valid values.");
}
list.Add(item);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
// Close the popup.
p.IsOpen = false;
currWinOpen = false;
}
Above is a example of how i use the Listbox.

New Topic/Question
Reply



MultiQuote


|