Bug with Visibility ?

6 posts, 0 answers
  1. x
    x avatar
    5 posts
    Member since:
    Jul 2010

    Posted 05 Jul 2010 Link to this post

    When binding and setting Visibility to Collapsed the item's empty space still remains. I have tested with many examples. Simple one is here

            <ListBox x:Name="HorizontalListBox">  
                <ListBox.ItemsPanel>  
                    <ItemsPanelTemplate>  
                        <telerik:RadCarouselPanel/>  
                    </ItemsPanelTemplate>  
                </ListBox.ItemsPanel>  
                <ListBox.ItemTemplate>  
                    <DataTemplate>  
                        <TextBlock Text="{Binding Name}" Visibility="{Binding Visible}" />  
                    </DataTemplate>  
                </ListBox.ItemTemplate>  
            </ListBox>  
            <Button Height="23" Width="70" Content="lol" Click="Button_Click" /> 

        public class Person : INotifyPropertyChanged  
        {  
            private int age;  
            private String name;  
     
            public Person(String name, int age)  
            {  
                this.name = name;  
                this.age = age;  
            }  
     
            public int Age  
            {  
                get { return this.age; }  
                set { this.age = value; }  
            }  
     
            public String Name  
            {  
                get { return this.name; }  
                set { this.name = value; }  
            }  
     
            Visibility _visible = Visibility.Visible;  
            public Visibility Visible  
            {  
                get { return _visible; }  
                set { _visible = value; OnPropertyChanged("Visible"); }  
            }
            #region INotifyPropertyChanged Members  
     
            public event PropertyChangedEventHandler PropertyChanged;  
            protected void OnPropertyChanged(string pname)  
            {  
                if (PropertyChanged != null)  
                    PropertyChanged(thisnew PropertyChangedEventArgs(pname));  
            }
            #endregion  
        }  
     
                  
     
            HorizontalListBox.ItemsSource = this.CreateItemSource(); // call from anywhere, like constructor  
     
            ObservableCollection<Person> list = new ObservableCollection<Person>();  
            private ObservableCollection<Person> CreateItemSource()  
            {  
                list.Add(new Person("George", 15));  
                list.Add(new Person("Rashko", 55));  
                list.Add(new Person("Britney", 60));  
                list.Add(new Person("Joe", 32));  
                list.Add(new Person("Vader", 34));  
                list.Add(new Person("Luke", 16));  
                list.Add(new Person("Jimmy", 105));  
                list.Add(new Person("Batman", 45));  
                list.Add(new Person("Butters", 9));  
                list.Add(new Person("Cartman", 9));  
                list.Add(new Person("Bender", 150));  
     
                return list;  
            }  
     
            private void Button_Click(object sender, RoutedEventArgs e)  
            {  
                list[3].Visible = System.Windows.Visibility.Collapsed;  
            } 

    Now, when you click the button you can see the 4th item got invisible but still taking the space. However if you remove ListBox.ItemsPanel tagand then check again it will be collapsed as it should.

    I have checked it with few examples and all are same, is there anyway to do that except removing the item from collection ?

  2. x
    x avatar
    5 posts
    Member since:
    Jul 2010

    Posted 06 Jul 2010 Link to this post

    anybody there or this forum is dead too like others ?
  3. UI for WPF is Visual Studio 2017 Ready
  4. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 08 Jul 2010 Link to this post

    Hello x,

    Setting the visibility of an item to Collapsed will not make the item disappear from the carousel. You can remove an item by either removing it from the source collection or use Filtering. 

    I have attached a sample project which demonstrated filtering with RadCarousel.


    Kind regards,
    Milan
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. x
    x avatar
    5 posts
    Member since:
    Jul 2010

    Posted 09 Jul 2010 Link to this post

    public Window1()
    {
        InitializeComponent();
        
        ListCollectionView view = new ListCollectionView(data);
        view.Filter = (yyyy) => ((Message)yyyy).Sender.Contains("jerry");
        RadCarousel1.ItemsSource = view;
        //view.Filter = (yyyy) => ((Message)yyyy).Sender.Contains("jerry");
          
        CustomCollectionView view2 = new CustomCollectionView(data);
        RadCarousel2.ItemsSource = view2;
    }

    Carousel doesn't place items in the middle when Filtering items right before/after setting ItemsSource. I have to click Navigate button to make it appear while they should be normal like without filter.

  6. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 14 Jul 2010 Link to this post

    Hello x,

    Currently RadCarousel will not auto scroll the items if their count is less than the ItemsPerPage property.

    If this case you could use the BringDataItemIntoView method to scroll the carousel to an item of your choosing:

    // subscribe for Loaded event
    private void RadCarousel1_Loaded(object sender, RoutedEventArgs e)
    {
        // bring the second item to front
        this.RadCarousel1.BringDataItemIntoView(this.RadCarousel1.Items[1]);
    }


    All the best,
    Milan
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. x
    x avatar
    5 posts
    Member since:
    Jul 2010

    Posted 14 Jul 2010 Link to this post

    too late, already found it 4 days ago.
Back to Top
UI for WPF is Visual Studio 2017 Ready