WindowStyle.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // -----------------------------------------------------------------------
  2. // <copyright file="WindowStyle.cs" company="Steven Kirk">
  3. // Copyright 2014 MIT Licence. See licence.md for more information.
  4. // </copyright>
  5. // -----------------------------------------------------------------------
  6. namespace Perspex.Themes.Default
  7. {
  8. using System.Linq;
  9. using Perspex.Controls;
  10. using Perspex.Controls.Presenters;
  11. using Perspex.Controls.Primitives;
  12. using Perspex.Controls.Templates;
  13. using Perspex.Styling;
  14. /// <summary>
  15. /// The default style for the <see cref="Window"/> control.
  16. /// </summary>
  17. public class WindowStyle : Styles
  18. {
  19. /// <summary>
  20. /// Initializes a new instance of the <see cref="WindowStyle"/> class.
  21. /// </summary>
  22. public WindowStyle()
  23. {
  24. this.AddRange(new[]
  25. {
  26. new Style(x => x.OfType<Window>())
  27. {
  28. Setters = new[]
  29. {
  30. new Setter(Window.TemplateProperty, new ControlTemplate<Window>(Template)),
  31. new Setter(Window.FontFamilyProperty, "Segoe UI"),
  32. new Setter(Window.FontSizeProperty, 12.0),
  33. },
  34. },
  35. });
  36. }
  37. /// <summary>
  38. /// The default template for the <see cref="Window"/> control.
  39. /// </summary>
  40. /// <param name="control">The control being styled.</param>
  41. /// <returns>The root of the instantiated template.</returns>
  42. public static Control Template(Window control)
  43. {
  44. return new Border
  45. {
  46. [~Border.BackgroundProperty] = control[~Window.BackgroundProperty],
  47. Child = new AdornerDecorator
  48. {
  49. Child = new ContentPresenter
  50. {
  51. Name = "contentPresenter",
  52. [~ContentPresenter.ContentProperty] = control[~Window.ContentProperty],
  53. }
  54. }
  55. };
  56. }
  57. }
  58. }