Program.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #if PERSPEX_GTK
  2. using Perspex.Gtk;
  3. #endif
  4. namespace XamlTestApplication
  5. {
  6. using System;
  7. using System.Diagnostics;
  8. using System.Windows.Threading;
  9. using Glass;
  10. using OmniXaml.AppServices.Mvvm;
  11. using OmniXaml.AppServices.NetCore;
  12. using Perspex;
  13. using Perspex.Collections;
  14. using Perspex.Controls;
  15. using Perspex.Controls.Templates;
  16. using Perspex.Input;
  17. using Perspex.Xaml.Desktop;
  18. using ReactiveUI;
  19. class Item
  20. {
  21. public string Name { get; set; }
  22. public string Value { get; set; }
  23. }
  24. class Node
  25. {
  26. public Node()
  27. {
  28. this.Children = new PerspexList<Node>();
  29. }
  30. public string Name { get; set; }
  31. public PerspexList<Node> Children { get; set; }
  32. }
  33. class Program
  34. {
  35. static void Main()
  36. {
  37. var foo = Dispatcher.CurrentDispatcher;
  38. App application = new App
  39. {
  40. DataTemplates = new DataTemplates
  41. {
  42. new TreeDataTemplate<Node>(
  43. x => new TextBlock { Text = x.Name },
  44. x => x.Children,
  45. x => true),
  46. },
  47. };
  48. var testCommand = ReactiveCommand.Create();
  49. testCommand.Subscribe(_ => Debug.WriteLine("Test command executed."));
  50. var typeFactory = new PerspexInflatableTypeFactory();
  51. var viewFactory = new ViewFactory(typeFactory);
  52. viewFactory.RegisterViews(ViewRegistration.FromTypes(Assemblies.AssembliesInAppFolder.AllExportedTypes()));
  53. var window = (Window) viewFactory.GetWindow("Main");
  54. window.Show();
  55. Application.Current.Run(window);
  56. }
  57. }
  58. }