Skip to main content

Microsoft Silverlight

Answered Question Problem with Jesse Liberty's Silverlight carousel!RSS Feed

(0)

Master Glink
Master G...

Member

Member

1 points

9 Posts

Problem with Jesse Liberty's Silverlight carousel!

I've done the whole tutorial, but when I tested the application the only thing visible is the background. I've tried modifying the color of the background and checking my code with Jesse Liberty's code to no avail. Here is the project and the code that I'm trying to use.

Mog Liang - MSFT
Mog Lian...

All-Star

All-Star

15854 points

1,541 Posts

Answered Question

Re: Problem with Jesse Liberty's Silverlight carousel!

Hi Master Glink,

I checked your code, found some problems:

1. Haven't set CarouselPanel's ItemSize. the default ItemSize is 0, that's the reason why we cann't see items (too small).

To fix this, set ItemSize to some value rather than 0. 

        <custom:CarouselPanel x:Name="cPanel"
                              Grid.Row="1"
                              ItemSize="100"
                              Width="{Binding Width}"
                              Height="{Binding Height}"
                              Speed="10"
                              UseMousePosition="{Binding Height}"
                              ScalePerspective="{Binding Height}"
                              Background="Bisque">
 2. 
        void timer_Tick(object sender, EventArgs e)
        {
            for (int i = 0; i < Children.Count; i++)
            {
                UIElement item = Children[ i ];
                double current = (double)item.GetValue(CarouselPanel.AngleProperty);
                item.SetValue(CarouselPanel.AngleProperty,
                    current + (InternalSpeed * (3.0 / 360) * (2 * Math.PI)));
            }
            DoArrange();
        }

  3 and 360 are int type. 3/360 = 0, so items never rotate. Change to 3.0/360 could fix this.

After these fixes, I can see the carousel wroking beautifully

Mog Liang
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.

Master Glink
Master G...

Member

Member

1 points

9 Posts

Re: Re: Problem with Jesse Liberty's Silverlight carousel!

Thank you! Yes I can see the carousel, however I can't adjust the controls...? It seems that the controls have no effect on the carousel...

I would expect to be something  with the binders that are used for the controls, but I can't tell for sure since this is still pretty new to me. I'll keep messing with it see if I can find something...

EDIT: Ok, I managed to make the carousel rotate at a reasonable speed, I had set some of the bindings for speed and scalePerspective to Height. I still can't control the carousel using the sliders and the checkbox, though.

EDIT: After some more tinkering I manged to get the Height, Width and Speed sliders functional. The only one giving me some trouble are the UseMousePosition Checkbox and the ScalePerspective Slider.

talldaniel
talldaniel

Member

Member

590 points

329 Posts

Re: Problem with Jesse Liberty's Silverlight carousel!

I downloaded that code and it will run in VS but wont run in expression blend 3.0

Master Glink
Master G...

Member

Member

1 points

9 Posts

Re: Problem with Jesse Liberty's Silverlight carousel!

talldaniel:

I downloaded that code and it will run in VS but wont run in expression blend 3.0

Well, I haven't tested in expression blend yet, the video was done with Visual Studio. I don't know much about how silverlight works yet so I can't help you open it.

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities