TabControlPage.xaml.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System;
  2. using Avalonia.Controls;
  3. using Avalonia.Media.Imaging;
  4. using Avalonia.Platform;
  5. using ControlCatalog.ViewModels;
  6. namespace ControlCatalog.Pages
  7. {
  8. public partial class TabControlPage : UserControl
  9. {
  10. public TabControlPage()
  11. {
  12. InitializeComponent();
  13. DataContext = new TabControlPageViewModel
  14. {
  15. Tabs = new[]
  16. {
  17. new TabControlPageViewModelItem
  18. {
  19. Header = "Arch",
  20. Text = "This is the first templated tab page.",
  21. Image = LoadBitmap("avares://ControlCatalog/Assets/delicate-arch-896885_640.jpg"),
  22. },
  23. new TabControlPageViewModelItem
  24. {
  25. Header = "Leaf",
  26. Text = "This is the second templated tab page.",
  27. Image = LoadBitmap("avares://ControlCatalog/Assets/maple-leaf-888807_640.jpg"),
  28. },
  29. new TabControlPageViewModelItem
  30. {
  31. Header = "Disabled",
  32. Text = "You should not see this.",
  33. IsEnabled = false,
  34. },
  35. },
  36. TabPlacement = Dock.Top,
  37. };
  38. }
  39. private static Bitmap LoadBitmap(string uri)
  40. {
  41. return new Bitmap(AssetLoader.Open(new Uri(uri)));
  42. }
  43. }
  44. }