コード例 #1
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;
        }
コード例 #2
0
 private void BindGridView()
 {
     GridViewLayout.DataSource = Columns;
     GridViewLayout.DataBind();
 }