This is a migrated thread and some comments may be shown as answers.

tilelist selecteditems error or bug?

1 Answer 32 Views
TileList
This is a migrated thread and some comments may be shown as answers.
Yilang
Top achievements
Rank 1
Yilang asked on 17 Aug 2016, 09:32 AM

first time set the ItemsSource then select one,the selecteditems's count is 1,

when reset the tilelist's ItemsSource,select one, the selecteditems count is 2,

        <telerik:RadTileList HorizontalAlignment="Left" ItemsSource="{Binding FpFieldDisplays,Mode=TwoWay}" SelectionMode="Multiple" VerticalAlignment="Top" SelectionChanged="RadTileList_SelectionChanged"/>
        <Button x:Name="button" Content="load" HorizontalAlignment="Left" Margin="385,271,0,0" VerticalAlignment="Top" Width="75" Click="button_Click"/>
        <Button x:Name="button_Copy" Content="count" HorizontalAlignment="Left" Margin="385,171,0,0" VerticalAlignment="Top" Width="75" Click="button1_Click"/>

 

backend

    /// </summary>
    public partial class MainWindow : Window
    {
        private vm vv = new vm();
        public MainWindow()
        {

            InitializeComponent();
            this.DataContext = vv;

        }


        private int cunt = 0;
        private void RadTileList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var tile = sender as Telerik.Windows.Controls.RadTileList;
            cunt = tile.SelectedItems.Count;
        }

        private void button_Click(object sender, RoutedEventArgs e)
        {
            vv.FpFieldDisplays = new ObservableCollection<itm>()
            {
                new itm() {Name ="21",value = "1" },
                new itm() {Name ="22",value = "2" },
                new itm() {Name ="21",value = "1" },
                new itm() {Name ="22",value = "2" },
                new itm() {Name ="21",value = "1" },
                new itm() {Name ="22",value = "2" },
                new itm() {Name ="21",value = "1" },
                new itm() {Name ="22",value = "2" },
                new itm() {Name ="23",value = "3" }
            };

        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            MessageBox.Show(cunt.ToString());
        }
    }
    public class vm : BindableBase
    {
        public vm()
        {
            FpFieldDisplays = new ObservableCollection<itm>()
            {
                new itm() {Name ="1",value = "1" },
                new itm() {Name ="2",value = "2" },
                new itm() {Name ="3",value = "3" }
            };

        }
        private ObservableCollection<itm> mFpFieldDisplays;
        public ObservableCollection<itm> FpFieldDisplays
        {
            get { return this.mFpFieldDisplays; }
            set { this.SetProperty(ref this.mFpFieldDisplays, value); }
        }

    }

    public class itm
    {
        public string Name { get; set; }
        public string value { get; set; }
    }

 

 

 

1 Answer, 1 is accepted

Sort by
0
Dilyan Traykov
Telerik team
answered on 19 Aug 2016, 11:22 AM
Hello ,

If you need to clear the SelectedItems collection when changing RadTileListView's ItemsSource you can simply call its Clear method, like so:

this.tileList.SelectedItems.Clear();
vv.FpFieldDisplays = new ObservableCollection<itm>()
{
    new itm() {Name ="21",value = "1" },
    new itm() {Name ="22",value = "2" },
    new itm() {Name ="21",value = "1" },
    new itm() {Name ="22",value = "2" },
    new itm() {Name ="21",value = "1" },
    new itm() {Name ="22",value = "2" },
    new itm() {Name ="21",value = "1" },
    new itm() {Name ="22",value = "2" },
    new itm() {Name ="23",value = "3" }
};

Would such an approach be suitable for your requirements?

Regards,
Dilyan Traykov
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
TileList
Asked by
Yilang
Top achievements
Rank 1
Answers by
Dilyan Traykov
Telerik team
Share this question
or