Advertisement
Guest User

xamwpf1

a guest
Dec 6th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.86 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Navigation;
  14. using System.Windows.Shapes;
  15. using Xamarin.Forms;
  16. using Xamarin.Forms.Platform.WPF;
  17.  
  18. namespace N2M_enwis.WPF
  19. {
  20. /// <summary>
  21. /// Interaction logic for MainWindow.xaml
  22. /// </summary>
  23. public partial class MainWindow : FormsApplicationPage
  24. {
  25.  
  26. public class mrenderer : IVisualElementRenderer
  27. {
  28. public VisualElement Element => throw new NotImplementedException();
  29.  
  30. public event EventHandler<VisualElementChangedEventArgs> ElementChanged;
  31.  
  32. public void Dispose()
  33. {
  34. throw new NotImplementedException();
  35. }
  36.  
  37. public SizeRequest GetDesiredSize(double widthConstraint, double heightConstraint)
  38. {
  39. throw new NotImplementedException();
  40. }
  41.  
  42. System.Windows.Controls.Grid ng = null;
  43. public FrameworkElement GetNativeElement()
  44. {
  45. if (ng == null)
  46. ng = new System.Windows.Controls.Grid();
  47. ng.Width = ng.Height = 200;
  48. ng.Background = new SolidColorBrush(System.Windows.Media.Color.FromRgb(0, 0, 55));
  49. return ng;
  50. }
  51.  
  52. public void SetElement(VisualElement element)
  53. {
  54. throw new NotImplementedException();
  55. }
  56. }
  57. public MainWindow()
  58. {
  59. StackLayout sl = new StackLayout();
  60.  
  61. InitializeComponent();
  62. Forms.Init();
  63. var app = new N2M_enwis.App();
  64. LoadApplication(app);
  65.  
  66. app.MainPage = new ContentPage();
  67. ((ContentPage)app.MainPage).Content = sl;
  68. app.MainPage.BackgroundColor = Xamarin.Forms.Color.Green;
  69. sl.WidthRequest = sl.HeightRequest = 1000;
  70. sl.BackgroundColor = Xamarin.Forms.Color.Yellow;
  71.  
  72. var rnd = Xamarin.Forms.Platform.WPF.Platform.GetOrCreateRenderer(sl);
  73. Xamarin.Forms.Platform.WPF.FormsPanel ffelem = (Xamarin.Forms.Platform.WPF.FormsPanel)rnd.GetNativeElement();
  74.  
  75. var newrend = new mrenderer();
  76. Xamarin.Forms.Platform.WPF.Platform.SetRenderer(sl, newrend);
  77.  
  78. ffelem.Background = new SolidColorBrush(System.Windows.Media.Color.FromRgb(150,150,255));
  79. ffelem.Opacity = 0.5;
  80.  
  81. var grid = new System.Windows.Controls.Grid();
  82. grid.Background = new SolidColorBrush(System.Windows.Media.Color.FromRgb(0, 0, 55));
  83. grid.Width = grid.Height = 200;
  84.  
  85. ffelem.Children.Add(grid);
  86. grid.BringIntoView();
  87. ffelem.Children.Add(new System.Windows.Controls.Button());
  88. ffelem.Children.Add(new System.Windows.Controls.Button());
  89. ffelem.Children.Add(new System.Windows.Controls.Button());
  90. ffelem.Children.Add(new System.Windows.Controls.Button());
  91. ffelem.Children.Add(new System.Windows.Controls.Button());
  92. grid.Children.Add(new System.Windows.Controls.Button());
  93. grid.Children.Add(new System.Windows.Controls.Button());
  94.  
  95. /*
  96. var btn = new System.Windows.Controls.Label();
  97. btn.Background = new SolidColorBrush(System.Windows.Media.Color.FromRgb(10, 10, 10));
  98. btn.MinWidth = 300;
  99. btn.MinHeight = 300;
  100. btn.Visibility = Visibility.Visible;
  101. btn.Content = "ztes";
  102. ffelem.Children.Add(btn);
  103. ffelem.UpdateLayout();*/
  104. }
  105. }
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement