1. Mankuji's Avatar
    My problem is : In my long list selector, when my list items loaded and i click on edit button to activate/inactive items

    When i active / d-activate the top items then on scrolling down long list selector the some- where middle items where automatically got selected.

    Please suggest something to me to get rid of this issue:

    MainPage.xaml

    sing System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Navigation;
    using Microsoft.Phone.Controls;
    using Microsoft.Phone.Shell;
    using longlistselector.Resources;
    using System.Windows.Media.Imaging;
    using System.Collections.ObjectModel;

    namespace longlistselector
    {
    public partial class MainPage : PhoneApplicationPage
    {
    // Constructor
    List<GroupClass> List = new List<GroupClass>();
    ObservableCollection<GroupClass> DataList = null;
    static bool IsEditable = false;
    public MainPage()
    {
    InitializeComponent();

    // Sample code to localize the ApplicationBar
    //BuildLocalizedApplicationBar();

    List.Add(new GroupClass() { Name = "Temp", IsActive = false, IsCustom = false, IsEditable = false, UnitGroupID = 1 });
    List.Add(new GroupClass() { Name = "Temp1", IsActive = false, IsCustom = false, IsEditable = false, UnitGroupID = 2 });
    List.Add(new GroupClass() { Name = "Temp2", IsActive = false, IsCustom = false, IsEditable = false, UnitGroupID = 3 });
    List.Add(new GroupClass() { Name = "Temp3", IsActive = false, IsCustom = false, IsEditable = false, UnitGroupID = 4 });
    List.Add(new GroupClass() { Name = "Aemp3", IsActive = false, IsCustom = false, IsEditable = false, UnitGroupID = 5 });
    List.Add(new GroupClass() { Name = "Aemp3", IsActive = false, IsCustom = false, IsEditable = false, UnitGroupID = 6 });
    List.Add(new GroupClass() { Name = "Aemp3", IsActive = false, IsCustom = false, IsEditable = false, UnitGroupID = 7 });
    List.Add(new GroupClass() { Name = "Bemp3", IsActive = false, IsCustom = false, IsEditable = false, UnitGroupID = 8 });
    List.Add(new GroupClass() { Name = "Bemp3", IsActive = false, IsCustom = false, IsEditable = false, UnitGroupID = 9 });
    List.Add(new GroupClass() { Name = "Bemp3", IsActive = false, IsCustom = false, IsEditable = false, UnitGroupID = 10 });
    List.Add(new GroupClass() { Name = "Cemp3", IsActive = false, IsCustom = false, IsEditable = false, UnitGroupID = 11 });
    List.Add(new GroupClass() { Name = "Cemp3", IsActive = false, IsCustom = false, IsEditable = false, UnitGroupID = 12 });
    List.Add(new GroupClass() { Name = "Cemp3", IsActive = false, IsCustom = false, IsEditable = false, UnitGroupID = 13 });
    List.Add(new GroupClass() { Name = "Demp3", IsActive = false, IsCustom = false, IsEditable = false, UnitGroupID = 14 });
    List.Add(new GroupClass() { Name = "Demp3", IsActive = false, IsCustom = false, IsEditable = false, UnitGroupID = 15 });
    List.Add(new GroupClass() { Name = "Demp3", IsActive = false, IsCustom = false, IsEditable = false, UnitGroupID = 16 });
    List.Add(new GroupClass() { Name = "Eemp3", IsActive = false, IsCustom = false, IsEditable = false, UnitGroupID = 17 });
    List.Add(new GroupClass() { Name = "Eemp3", IsActive = false, IsCustom = false, IsEditable = false, UnitGroupID = 18 });
    List.Add(new GroupClass() { Name = "Eemp3", IsActive = false, IsCustom = false, IsEditable = false, UnitGroupID = 19 });
    List.Add(new GroupClass() { Name = "Eemp3", IsActive = false, IsCustom = false, IsEditable = false, UnitGroupID = 20 });
    List.Add(new GroupClass() { Name = "Femp3", IsActive = false, IsCustom = false, IsEditable = false, UnitGroupID = 21 });
    List.Add(new GroupClass() { Name = "Femp3", IsActive = false, IsCustom = false, IsEditable = false, UnitGroupID = 22 });
    List.Add(new GroupClass() { Name = "Gemp3", IsActive = false, IsCustom = false, IsEditable = false, UnitGroupID = 23 });
    List.Add(new GroupClass() { Name = "Gemp3", IsActive = false, IsCustom = false, IsEditable = false, UnitGroupID = 24 });
    List.Add(new GroupClass() { Name = "Hemp3", IsActive = false, IsCustom = false, IsEditable = false, UnitGroupID = 25 });
    List.Add(new GroupClass() { Name = "Hemp3", IsActive = false, IsCustom = false, IsEditable = false, UnitGroupID = 26 });
    List.Add(new GroupClass() { Name = "Jemp3", IsActive = false, IsCustom = false, IsEditable = false, UnitGroupID = 27 });
    List.Add(new GroupClass() { Name = "Jemp3", IsActive = false, IsCustom = false, IsEditable = false, UnitGroupID = 28 });

    DataList = new ObservableCollection<GroupClass>(List);
    this.GroupListBox.ItemsSource = DataList;

    }

    private void ActiveInactiveImage_Tap_1(object sender, System.Windows.Input.GestureEventArgs e)
    {

    Image imgobj = sender as Image;
    GroupClass gcobj = (GroupClass)imgobj.DataContext;
    if (gcobj != null)
    {
    gcobj.IsActive = !gcobj.IsActive;

    imgobj.DataContext = gcobj;

    DataList.FirstOrDefault(x => x.UnitGroupID == gcobj.UnitGroupID).IsActive = gcobj.IsActive;

    imgobj.Source = new BitmapImage(new Uri(gcobj.IsActive ? "/Assets/Images/Active.png" : "/Assets/Images/Inactive.png", UriKind.Relative));

    }

    GroupListBox.ItemsSource = DataList;
    }

    private void ApplicationBarIconButton_Click_1(object sender, EventArgs e)
    {
    IsEditable = !IsEditable;
    foreach (var obj in DataList)
    {
    obj.IsEditable = IsEditable; obj.IsChecked = false;

    }
    this.GroupListBox.ItemsSource = null;
    this.GroupListBox.ItemsSource = DataList;

    }
    }
    }

    GroupClass.cs :

    sing System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;

    namespace longlistselector
    {
    class GroupClass
    {

    public string ImageSource
    {
    get;
    set;
    }
    public string Content
    {
    get { return IsActive ? "/Assets/Images/Active.png" : "/Assets/Images/Inactive.png"; }

    }
    public string Name
    {
    get;
    set;
    }
    public long UnitGroupID
    {
    get;
    set;
    }
    public bool IsActive
    {
    get;

    set;

    }

    public bool IsCustom
    {
    get;
    set;
    }
    public bool IsChecked
    {
    get;
    set;
    }
    public bool IsEditable
    {
    get
    ;
    set;

    }

    public Visibility ControlVisibility
    {
    get { return IsEditable? Visibility.Visible : Visibility.Collapsed; }
    }

    }
    }
    03-30-2015 09:45 AM

Similar Threads

  1. Replies: 1
    Last Post: 03-31-2015, 07:50 AM
  2. How can I delete storage sense on my Lumia 920?
    By Windows Central Question in forum Nokia Lumia 920
    Replies: 3
    Last Post: 03-30-2015, 04:14 PM
  3. Pinball FX2 adding Star Wars Rebels table in late April for Xbox One and Xbox 360
    By WindowsCentral.com in forum Windows Central News Discussion
    Replies: 0
    Last Post: 03-30-2015, 08:30 AM
LINK TO POST COPIED TO CLIPBOARD