Пример #1
0
 private void ClearLayout()
 {
     System.Windows.Controls.ContentControl contentControl = ViewsManager.FindViewContent(this);
     if (contentControl.Content == null)
     {
         return;
     }
     System.Windows.Controls.Grid grid = (System.Windows.Controls.Grid)contentControl.Content;
     contentControl.Content = null;
     grid.Children.Clear();
 }
Пример #2
0
        private void ApplyLayout()
        {
            ClearLayout();
            GridViewLayout layout = new GridViewLayout(ViewModel);

            layout.BuildGrid();
            System.Windows.Controls.Grid grid = new System.Windows.Controls.Grid();
            grid.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            grid.VerticalAlignment   = System.Windows.VerticalAlignment.Stretch;
            for (int row = 0; row < layout.Rows; row++)
            {
                System.Windows.Controls.RowDefinition rowDefinition = new System.Windows.Controls.RowDefinition();
                bool isFixedHeight = layout.GetIsFixedHeight(row);
                if (isFixedHeight)
                {
                    rowDefinition.Height = System.Windows.GridLength.Auto;
                }
                else
                {
                    rowDefinition.Height = new System.Windows.GridLength(1, System.Windows.GridUnitType.Star);
                }
                grid.RowDefinitions.Add(rowDefinition);
            }
            for (int column = 0; column < layout.Columns; column++)
            {
                System.Windows.Controls.ColumnDefinition columnDefinition = new System.Windows.Controls.ColumnDefinition();
                bool isFixedHeight = layout.GetIsFixedWidth(column);
                if (isFixedHeight)
                {
                    columnDefinition.Width = System.Windows.GridLength.Auto;
                }
                else
                {
                    columnDefinition.Width = new System.Windows.GridLength(1, System.Windows.GridUnitType.Star);
                }
                grid.ColumnDefinitions.Add(columnDefinition);
            }
            foreach (GridViewLayoutItem item in layout)
            {
                grid.Children.Add(item.View);
            }
            System.Windows.Controls.ContentControl contentControl = ViewsManager.FindViewContent(this);
            contentControl.Content = grid;
        }
Пример #3
0
        private void CreateTabControl()
        {
            System.Windows.Controls.TabControl tabControl = new System.Windows.Controls.TabControl();
            tabControl.DataContext = _context;

            //Set templates
            tabControl.ItemTemplate    = (System.Windows.DataTemplate)System.Windows.Application.Current.Resources["TabViewHeaderDataTempate"];
            tabControl.ContentTemplate = (System.Windows.DataTemplate)System.Windows.Application.Current.Resources["TabViewContentDataTempate"];

            //Set ItemsSource binding
            Binding itemsSourceBinding = new Binding(".");

            tabControl.SetBinding(System.Windows.Controls.ItemsControl.ItemsSourceProperty, itemsSourceBinding);

            //Set SelectedItem binding
            Binding selectedItemBinding = new Binding("ActiveItem");

            selectedItemBinding.Mode = BindingMode.TwoWay;
            tabControl.SetBinding(System.Windows.Controls.Primitives.Selector.SelectedItemProperty, selectedItemBinding);

            //Put TabControl on view
            System.Windows.Controls.ContentControl contentControl = ViewsManager.FindViewContent(this);
            contentControl.Content = tabControl;
        }