Skip to main content
Home Forums General Silverlight Getting Started Problem with Jesse Liberty's Silverlight carousel!
4 replies. Latest Post by Master Glink on July 9, 2009.
(0)
Master G...
Member
1 points
9 Posts
07-06-2009 11:05 AM |
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 Lian...
All-Star
15854 points
1,541 Posts
07-09-2009 4:11 AM |
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">
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
07-09-2009 2:11 PM |
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
590 points
329 Posts
07-09-2009 4:07 PM |
I downloaded that code and it will run in VS but wont run in expression blend 3.0
07-09-2009 4:22 PM |
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.