tilelist selecteditems error or bug?

2 posts, 0 answers
  1. Yilang
    Yilang avatar
    11 posts
    Member since:
    Jan 2016

    Posted 17 Aug Link to this post

    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; }
        }

     

     

     

  2. Dilyan Traykov
    Admin
    Dilyan Traykov avatar
    371 posts

    Posted 19 Aug Link to this post

    Hello Yilang,

    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.
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top