Example #1
0
 /// <summary>
 /// The default template for the <see cref="Deck"/> control.
 /// </summary>
 /// <param name="control">The control being styled.</param>
 /// <returns>The root of the instantiated template.</returns>
 public static Control Template(Deck control)
 {
     return new DeckPresenter
     {
         Name = "itemsPresenter",
         [~ItemsPresenter.ItemsProperty] = control[~ItemsControl.ItemsProperty],
         [~ItemsPresenter.ItemsPanelProperty] = control[~ItemsControl.ItemsPanelProperty],
         [~DeckPresenter.SelectedIndexProperty] = control[~SelectingItemsControl.SelectedIndexProperty],
         [~DeckPresenter.TransitionProperty] = control[~Deck.TransitionProperty],
     };
 }
Example #2
0
 private Control Template(Deck control)
 {
     return new DeckPresenter
     {
         Name = "itemsPresenter",
         [~ItemsPresenter.ItemsProperty] = control[~Deck.ItemsProperty],
         [~ItemsPresenter.ItemsPanelProperty] = control[~Deck.ItemsPanelProperty],
         [~DeckPresenter.SelectedIndexProperty] = control[~Deck.SelectedIndexProperty],
         [~DeckPresenter.TransitionProperty] = control[~Deck.TransitionProperty],
     };
 }
Example #3
0
        protected override void OnTemplateApplied()
        {
            base.OnTemplateApplied();

            this.deck = this.GetTemplateChild<Deck>("deck");
            this.logicalChildren.Source = ((ILogical)deck).LogicalChildren;
        }
Example #4
0
		private static TabItem ImagesTab() 
		{
			var imageDeck = new Deck 
			{
				Width = 400,
				Height = 400,
				Transition = new PageSlide(TimeSpan.FromSeconds(0.25)),
				Items = new[] 
				{
					new Image { Source = new Bitmap("github_icon.png"),  Width = 400, Height = 400 },
					new Image { Source = new Bitmap("pattern.jpg"), Width = 400, Height = 400 },
				}
			};

			imageDeck.AutoSelect = true;

			var next = new Button 
			{
				VerticalAlignment = VerticalAlignment.Center,
				Padding = new Thickness(20),
				Content = new Perspex.Controls.Shapes.Path 
				{
					Data = StreamGeometry.Parse("M4,11V13H16L10.5,18.5L11.92,19.92L19.84,12L11.92,4.08L10.5,5.5L16,11H4Z"),
					Fill = Brushes.Black
				}
			};

			var prev = new Button 
			{
				VerticalAlignment = VerticalAlignment.Center,
				Padding = new Thickness(20),
				Content = new Perspex.Controls.Shapes.Path 
				{
					Data = StreamGeometry.Parse("M20,11V13H8L13.5,18.5L12.08,19.92L4.16,12L12.08,4.08L13.5,5.5L8,11H20Z"),
					Fill = Brushes.Black
				}
			};

			prev.Click += (s, e) => 
			{
				if (imageDeck.SelectedIndex == 0)
					imageDeck.SelectedIndex = 1;
				else
					imageDeck.SelectedIndex--;
			};

			next.Click += (s, e) => 
			{
				if (imageDeck.SelectedIndex == 1)
					imageDeck.SelectedIndex = 0;
				else
					imageDeck.SelectedIndex++;
			};

			return new TabItem
			{
				Header = "Images",
				Content = new ScrollViewer 
				{
					Content = new StackPanel 
					{
						HorizontalAlignment = HorizontalAlignment.Left,
						Orientation = Orientation.Vertical,
						VerticalAlignment = VerticalAlignment.Top,
						Gap = 4,
						Margin = new Thickness(10),
						Children = new Controls 
						{
							new TextBlock
							{
								Text = "Deck",
								FontWeight = FontWeight.Medium,
								FontSize = 20,
								Foreground = SolidColorBrush.Parse("#212121"),
							},
							new TextBlock
							{
								Text = "An items control that displays its items as pages that fill the controls.",
								FontSize = 13,
								Foreground = SolidColorBrush.Parse("#727272"),
								Margin = new Thickness(0, 0, 0, 10)
							},
							new StackPanel 
							{
								Name = "deckVisual",
								Orientation = Orientation.Horizontal,
								Gap = 4,
								Children = new Controls
								{								
									prev,
									imageDeck,
									next
								}
							}
						}
					}
				}
			};
		}