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

Bug with Visibility ?

5 Answers 618 Views
Carousel
This is a migrated thread and some comments may be shown as answers.
x
Top achievements
Rank 1
x asked on 05 Jul 2010, 11:37 AM

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 ?

5 Answers, 1 is accepted

Sort by
0
x
Top achievements
Rank 1
answered on 06 Jul 2010, 04:20 PM
anybody there or this forum is dead too like others ?
0
Milan
Telerik team
answered on 08 Jul 2010, 11:42 AM
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
0
x
Top achievements
Rank 1
answered on 09 Jul 2010, 02:02 PM
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.

0
Milan
Telerik team
answered on 14 Jul 2010, 02:55 PM
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
0
x
Top achievements
Rank 1
answered on 14 Jul 2010, 04:09 PM
too late, already found it 4 days ago.
Tags
Carousel
Asked by
x
Top achievements
Rank 1
Answers by
x
Top achievements
Rank 1
Milan
Telerik team
Share this question
or