Coverflow not redrawn properly when items removed/added

Sep 16, 2010 at 4:57 AM

Hello there, first of all, thanks for a fantastic component.

The problem I'm having is that I clearing out and reloading an Observable collection which the coverflow is using as a ItemSource. Sometimes, everything is drawn correctly, othertimes, only the first/ front record is drawn... Only after I 'move' the flow along (with cursor), is the coverflow redrawn correctly... I've even tried reloading, nullifying, etc...

What would be the recommended approach so that the coverflow is redrawn correctly..

            _wiredLinks.Clear();
            _wiredLinks = null;

            _wiredLinks = new ObservableCollection<MenuLink>();
            _currentMenu.Links.ForEach(x => _wiredLinks.Add(x));
            flow.ItemsSource = _wiredLinks;
          
            flow.SelectedIndex = selectedIndex;

            flow.UpdateLayout();
            flow.ApplyTemplate();

thanks

Mathew

Sep 16, 2010 at 7:49 AM
Hi Mathew,
Could you please send me a simple repro ? This seems to be a very serious bug.
How many items are in the collections when you get this problem ?
When you change the collection on which the FlowItemsControl is bound, is it a full reset or just adding / removing some random items ?
And the most important : what is your platform ? WPF, SL4 or WP7 ?
Thanks for these precisions,
Simon
From: [email removed]
Sent: Thursday, September 16, 2010 5:58 AM
To: [email removed]
Subject: Coverflow not redrawn properly when items removed/added [slflow:227409]

From: mathew_123456

Hello there, first of all, thanks for a fantastic component.

The problem I'm having is that I clearing out and reloading an Observable collection which the coverflow is using as a ItemSource. Sometimes, everything is drawn correctly, othertimes, only the first/ front record is drawn... Only after I 'move' the flow along (with cursor), is the coverflow redrawn correctly... I've even tried reloading, nullifying, etc...

What would be the recommended approach so that the coverflow is redrawn correctly..

            _wiredLinks.Clear();
            _wiredLinks = null;

            _wiredLinks = new ObservableCollection<MenuLink>();
            _currentMenu.Links.ForEach(x => _wiredLinks.Add(x));
            flow.ItemsSource = _wiredLinks;
          
            flow.SelectedIndex = selectedIndex;

            flow.UpdateLayout();
            flow.ApplyTemplate();

thanks

Mathew

Sep 17, 2010 at 2:48 AM

platform is WPF

was having issue with 5/6 in collection. It seems to 'rectify' itself when I resize the window...Full reset in regards to collection. I set ItemSource of Flow (which is FlowItemsControl3D) to null, then load up a new observable collection, then set itemSource to new collection)... It is intermittent

// on initialisation
_wiredLinks = new ObservableCollection<MenuLink>();

// when loading a menu level (reloading the collection..)

flow.ItemsSource = null;
flow.SelectedIndex = -1;

_wiredLinks = new ObservableCollection<MenuLink>();
_currentMenu.Links.ForEach(x => _wiredLinks.Add(x));
flow.ItemsSource = _wiredLinks;

flow.SelectedIndex = selectedIndex;

Data template I'm using...
<DataTemplate x:Key="itemTemplate">
	<Viewbox>
		<Border Width="400" Height="400" Margin="1" CornerRadius="15">
			<Image Source="{Binding Path=Image}" />
		</Border>
	</Viewbox>
</DataTemplate>

thanks again

Mathew

Sep 17, 2010 at 6:56 AM
Hi,
Can you download the source-code version, and on the FlowItemsControl3D, override the OnItemsChanged method and call “this.InvalidateMeasure(); this.InvalidateLayout();” ? If it works, I’ll put the fix in the Source control.
Simon
From: [email removed]
Sent: Friday, September 17, 2010 3:48 AM
To: [email removed]
Subject: Re: Coverflow not redrawn properly when items removed/added [slflow:227409]

From: mathew_123456

platform is WPF

was having issue with 5/6 in collection. It seems to 'rectify' itself when I resize the window...Full reset in regards to collection. I set ItemSource of Flow (which is FlowItemsControl3D) to null, then load up a new observable collection, then set itemSource to new collection)... It is intermittent

// on initialisation
_wiredLinks = new ObservableCollection<MenuLink>();

// when loading a menu level (reloading the collection..)

flow.ItemsSource = null;
flow.SelectedIndex = -1;

_wiredLinks = new ObservableCollection<MenuLink>();
_currentMenu.Links.ForEach(x => _wiredLinks.Add(x));
flow.ItemsSource = _wiredLinks;

flow.SelectedIndex = selectedIndex;

Data template I'm using...
<DataTemplate x:Key="itemTemplate">
	<Viewbox>
		<Border Width="400" Height="400" Margin="1" CornerRadius="15">
			<Image Source="{Binding Path=Image}" />
		</Border>
	</Viewbox>
</DataTemplate>

thanks again

Mathew

Sep 23, 2010 at 12:34 AM

I'm not really that great of a programmer :D

I'm just checking I understand correctly... In the file 'FlowItemsControl3D.cs'... I already find this entry

        /// <summary>
        /// Handles changes in the collection of items
        /// </summary>
        /// <param name="e"></param>
        protected override void OnItemsChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            base.OnItemsChanged(e);
            if (_panel != null)
                _panel.ItemCount = Items.Count;
        }

I'm guessing you are specifying the following changes to this method...

base.OnItemsChanged(e); 
if (_panel != null) {
     _panel.ItemCount = Items.Count; 
     this.InvalidateMeasure(); 
     this.InvalidateLayout(); //??? not sure if this exists???
}

Mathew

Sep 23, 2010 at 8:03 AM
Yes, that’s it,
Replace InvalidateLayout by InvalidateArrange (sorry for the misspelling)
Simon
From: [email removed]
Sent: Thursday, September 23, 2010 1:34 AM
To: [email removed]
Subject: Re: Coverflow not redrawn properly when items removed/added [slflow:227409]

From: mathew_123456

I'm not really that great of a programmer :D

I'm just checking I understand correctly... In the file 'FlowItemsControl3D.cs'... I already find this entry

        /// <summary>
        /// Handles changes in the collection of items
        /// </summary>
        /// <param name="e"></param>
        protected override void OnItemsChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            base.OnItemsChanged(e);
            if (_panel != null)
                _panel.ItemCount = Items.Count;
        }

I'm guessing you are specifying the following changes to this method...

base.OnItemsChanged(e); 
if (_panel != null) {
     _panel.ItemCount = Items.Count; 
     this.InvalidateMeasure(); 
     this.InvalidateLayout(); //??? not sure if this exists???
}

Mathew
Dec 11, 2010 at 12:37 PM
Edited Dec 11, 2010 at 1:04 PM

I have the same problem ("only the front record is drawn"). The suggest fix does not correct it when a filter is applied to the source object.

In the OnItemsChangedEvent, the Items.Count is correct, but the items are not drawn.

Dec 13, 2010 at 6:48 AM

I'll investigate on this as soon as I can !