Question

Hi am using xaml file and code given below. I want to get two categories one is current categories and other one is removed categories.If i remove one category it should go to add current category.I don't have any idea about this.so please can any one tell me how to resolve this issue.

<StackPanel>
      <TextBlock Text="Current categories"
                           Style="{StaticResource PhoneTextLargeStyle}"/>

       <ListBox x:Name="AddingList" ItemsSource="{Binding name}" SelectionChanged="AddingList_SelectionChanged_1"/>

        <TextBlock Text="Removed categories"
                           Style="{StaticResource PhoneTextLargeStyle}" />

        <ListBox x:Name="RemoveList" ItemsSource="{Binding name}" SelectionChanged="RemoveList_SelectionChanged_1"/>

 </StackPanel>

my xaml.cs code

    private void Button_Click_1(object sender, RoutedEventArgs e)
    {

        NavigationService.Navigate(new Uri("/CategoriesPage.xaml?" + NotchsList11, UriKind.Relative));

    }

I am using edit button, How can i pass listbox item from edit button to categories page and how remove and add listbox items.

My out put want given below image so please help me some one enter image description here

Was it helpful?

Solution

Few ways of going about this. One way is to have a single object that has "isRemoved" boolean on it that you just turn on and off. Another way is you could have 2 observablecollections one holding the added, and one holding the removed. so for example:

class:

public class MyData
{
    public bool isRemoved { get; set; }
    public string Name { get; set; }
}

Use:

ObservableCollection<MyData> AllData = new ObservableCollection<MyData>()
AllData.Add(new MyData(){ isRemoved = true, Name = "Data1"}
AllData.Add(new MyData(){ isRemoved = true, Name = "Data2"}
AllData.Add(new MyData(){ isRemoved = false, Name = "Data3"}

AddingList.ItemsSource = AllData.Where(srch => srch.isRemoved == false);
RemoveList.ItemsSource = AllData.Where(srch => srch.isRemoved == true);

In your Remove button click you just set the isRemoved to true and in your Add you set the isRemoved to false.

or you could use 2 ObservableCollections adding and removing from each.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top