Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. <Page
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  4. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  5. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  6. xmlns:viewModels="using:Client.ViewModel"
  7. x:Class="Client.View.ViewMain"
  8. mc:Ignorable="d">
  9.  
  10. <Grid x:Name="ContentGrid" RequestedTheme="Light">
  11. <Grid.ColumnDefinitions>
  12. <ColumnDefinition Width="Auto"/>
  13. <ColumnDefinition Width="Auto"/>
  14. <ColumnDefinition Width="Auto"/>
  15. </Grid.ColumnDefinitions>
  16. <StackPanel Name="FeatureLeft" Orientation="Horizontal" Grid.Column="0"/>
  17. <StackPanel Name="FeatureCenter" Orientation="Horizontal" Grid.Column="1"/>
  18. <StackPanel Name="FeatureRight" Orientation="Horizontal" Grid.Column="2"/>
  19. </Grid>
  20. </Page>
  21.  
  22. public sealed partial class ViewMain : Page
  23. {
  24.  
  25. public ViewModelMain viewModelMain;
  26.  
  27. public ViewMain()
  28. {
  29. this.InitializeComponent();
  30. viewModelMain = new ViewModelMain();
  31. viewModelMain.RegisterFeatures(this);
  32. }
  33. }
  34.  
  35. public class ViewModelMain: NotificationBase
  36. {
  37. public ModelMain model;
  38. public ViewModelMain()
  39. {
  40. model = new ModelMain();
  41. _Features = model.LoadFeatures();
  42. }
  43.  
  44. public void RegisterFeatures(Page p)
  45. {
  46. foreach (var feature in _Features)
  47. {
  48. feature.AddToView(p);
  49. }
  50. }
  51.  
  52. ObservableCollection<IViewFeature> _Features = new ObservableCollection<IViewFeature>();
  53. public ObservableCollection<IViewFeature> Features {
  54. get { return _Features; }
  55. set { SetProperty(ref _Features, value); }
  56. }
  57.  
  58. }
  59.  
  60. public class ModelMain
  61. {
  62.  
  63. public ObservableCollection<IViewFeature> FeatureList;
  64.  
  65.  
  66. public ObservableCollection<IViewFeature> LoadFeatures()
  67. {
  68. FeatureList = new ObservableCollection<IViewFeature>();
  69. IViewFeature galleryFeature = new Gallery.View.ViewGallery();
  70. FeatureList.Add(galleryFeature);
  71.  
  72. return FeatureList;
  73. }
  74.  
  75. }
  76.  
  77. public void AddToView( Page p)
  78. {
  79. StackPanel target = (StackPanel)p.FindName("FeatureLeft");
  80. target.Children.Add(this);
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement