当前位置: 首页>>代码示例>>C#>>正文


C# StackPanel.SetValue方法代码示例

本文整理汇总了C#中System.Windows.Controls.StackPanel.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# StackPanel.SetValue方法的具体用法?C# StackPanel.SetValue怎么用?C# StackPanel.SetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Controls.StackPanel的用法示例。


在下文中一共展示了StackPanel.SetValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddUI

        public override void AddUI(Grid grid)
        {
            if (Config != null && Config.ShownAtRunTime)
            {
                grid.RowDefinitions.Add(new RowDefinition());
                #region
                StackPanel g = new StackPanel() { Orientation = System.Windows.Controls.Orientation.Horizontal, Margin=new Thickness(5,0,0,0) };

                TextBlock lblUrl = new TextBlock() { VerticalAlignment = System.Windows.VerticalAlignment.Center, Margin = new Thickness(2) };
                lblUrl.Text = Resources.Strings.LabelUrl;
                g.Children.Add(lblUrl);

                TextBox tbFormat = new TextBox() { Margin = new Thickness(4,2,0,2), Width = 50, MaxWidth= 60 };
                TextBox tb = new TextBox() { 
                    Margin = new Thickness(2), 
                    HorizontalAlignment = HorizontalAlignment.Stretch
                };
                tb.SetValue(ToolTipService.ToolTipProperty, Config.ToolTip);
                if (value != null)
                    tb.Text = value.Url.ToString();

                tb.TextChanged += (s, e) =>
                {
                    if (value == null)
                        Value = new GPRasterData(Config.Name, tb.Text, tbFormat.Text) { Format = tbFormat.Text };//Workaround for slapi bug
                    else
                        value.Url = tb.Text;
                    RaiseCanExecuteChanged();
                };
                g.Children.Add(tb);

                TextBlock lbl = new TextBlock() { VerticalAlignment = System.Windows.VerticalAlignment.Center, Margin = new Thickness(2) };
                lbl.Text = Resources.Strings.LabelFormat;
                g.Children.Add(lbl);

                if (Config is RasterDataParameterConfig)
                    tbFormat.SetValue(ToolTipService.ToolTipProperty, (Config as RasterDataParameterConfig).FormatToolTip);
                if (value != null)
                    tbFormat.Text = value.Format.ToString();
                tbFormat.TextChanged += (s, e) =>
                {
                    if (value == null)
                        Value = new GPRasterData(Config.Name, tb.Text, tbFormat.Text) { Format = tbFormat.Text };//Workaround for slapi bug
                    else
                        value.Format = tbFormat.Text;
                    RaiseCanExecuteChanged();
                };
                g.Children.Add(tbFormat);

                g.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1);
                g.SetValue(Grid.ColumnProperty, 0);
                g.SetValue(Grid.ColumnSpanProperty, 2);
                grid.Children.Add(g);
                RaiseCanExecuteChanged();
                #endregion
            }
        }
开发者ID:yulifengwx,项目名称:arcgis-viewer-silverlight,代码行数:57,代码来源:RasterParameter.cs

示例2: MostrarGrade

        private void MostrarGrade()
        {
            TxtCurso.Text = Context.Grade.NomeCurso;
            TxtDia.Text = Context.Grade.NomeDia;
            TxtSemestre.Text = Context.Grade.NumeroSemestre.ToString();

            for (int i = 0; i < Context.Grade.Horarios.Count; i++)
            {
                if (i > 0 && Context.Grade.Horarios[i].HorarioInicial != Context.Grade.Horarios[i - 1].HorarioFinal)
                {
                    Tabela.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(30) });
                    var intervalo = new TextBlock()
                    {
                        Text = "Intervalo",
                        TextAlignment = System.Windows.TextAlignment.Center,
                        Background = Brushes.LightGray,
                        Width = Tabela.Width,
                        VerticalAlignment = System.Windows.VerticalAlignment.Center,
                        HorizontalAlignment = System.Windows.HorizontalAlignment.Center
                    };
                    intervalo.SetValue(Grid.ColumnSpanProperty, 2);
                    intervalo.SetValue(Grid.RowProperty, Tabela.RowDefinitions.Count - 1);
                    Tabela.Children.Add(intervalo);
                }

                Tabela.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(50) });
                var horario = new TextBlock()
                {
                    Text = string.Concat(Context.Grade.Horarios[i].HorarioInicial, " - ", Context.Grade.Horarios[i].HorarioFinal),
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment = VerticalAlignment.Center
                };
                horario.SetValue(Grid.ColumnProperty, 0);
                horario.SetValue(Grid.RowProperty, Tabela.RowDefinitions.Count - 1);

                var materia = new StackPanel()
                {
                    Orientation = Orientation.Vertical,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment = VerticalAlignment.Center
                };
                if (Context.Grade.Horarios[i].Materia != null)
                {
                    materia.Children.Add(new TextBlock() { Text = Context.Grade.Horarios[i].Materia.Materia, FontWeight = FontWeight.FromOpenTypeWeight(600) });
                    materia.Children.Add(new TextBlock() { Text = Context.Grade.Horarios[i].Materia.Professor });
                }
                materia.SetValue(Grid.ColumnProperty, 1);
                materia.SetValue(Grid.RowProperty, Tabela.RowDefinitions.Count - 1);

                Tabela.Children.Add(horario);
                Tabela.Children.Add(materia);
            }
        }
开发者ID:angelcdz,项目名称:SistemaHorarios,代码行数:53,代码来源:ExibirGrade.xaml.cs

示例3: AddUI

 public override void AddUI(Grid grid)
 {
     if (Config != null && Config.ShownAtRunTime && Map != null)
     {
         #region
         ParameterSupport.FeatureLayerParameterConfig flConfig = Config as ParameterSupport.FeatureLayerParameterConfig;
         #region Get layer list
         List<GraphicsLayer> inputLayers = GetLayerList();
         #endregion
         Map.Layers.CollectionChanged -= Layers_CollectionChanged;
         Map.Layers.CollectionChanged += Layers_CollectionChanged;
         layerPanel = new StackPanel();
         layerPanel.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1);
         layerPanel.SetValue(Grid.ColumnProperty, 1);
         grid.Children.Add(layerPanel);
         populateLayerPanel(inputLayers);
         #endregion
     }
 }
开发者ID:yulifengwx,项目名称:arcgis-viewer-silverlight,代码行数:19,代码来源:SelectExistingLayerParameter.cs

示例4: SetChoices

 private void SetChoices(Platform platform)
 {
     if ( dynamicStackPanel != null )
         dynamicStackPanel.Children.Clear();
     dynamicStackPanel = new StackPanel();
     dynamicStackPanel.Orientation = Orientation.Horizontal;
     dynamicStackPanel.SetValue(Grid.RowProperty, 1);
     dynamicStackPanel.SetValue(Grid.ColumnProperty, 3);
     if (platform == Platform.Desktop)
     {
         CheckBox cb = new CheckBox();
         cb.Content = "Winforms";
         cb.Height = 30;
         cb.Width = 90;
         dynamicStackPanel.Children.Add(cb);
         cb = new CheckBox();
         cb.Content = "WPF";
         cb.Height = 30;
         cb.Width = 50;
         dynamicStackPanel.Children.Add(cb);
     }
     else
     {
         CheckBox cb = new CheckBox();
         cb.Content = "AJAX";
         cb.Height = 30;
         cb.Width = 60;
         dynamicStackPanel.Children.Add(cb);
         cb = new CheckBox();
         cb.Content = "Silverlight";
         cb.Height = 30;
         cb.Width = 90;
         dynamicStackPanel.Children.Add(cb);
     }
     LayoutRoot.Children.Add(dynamicStackPanel);
 }
开发者ID:gawallsibya,项目名称:BIT_MFC-CShap-DotNet,代码行数:36,代码来源:Page.xaml.cs

示例5: MakeListItem

        public static UIElement MakeListItem(MyroConfigFiles myroConfig)
        {
            Grid s1 = new Grid() { HorizontalAlignment = HorizontalAlignment.Stretch };
            s1.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
            s1.ColumnDefinitions.Add(new ColumnDefinition());
            StackPanel s2 = new StackPanel()
            {
                VerticalAlignment = VerticalAlignment.Center,
                Orientation = Orientation.Vertical
            };
            s2.SetValue(Grid.ColumnProperty, 1);
            Label l1 = new Label()
            {
                Content = myroConfig.BaseName,
                Padding = new Thickness(0, 0, 5, 0)
            };
            Label l2 = new Label()
            {
                Content =
                    myroConfig.MyroConfigExisted ?
                    myroConfig.MyroConfiguration.FriendlyName :
                    "No Myro configuration",
                Padding = new Thickness(0, 0, 5, 0)
            };
            Image i = new Image()
            {
                VerticalAlignment = VerticalAlignment.Center,
                Width = 64,
                Height = 64,
                Margin = new Thickness(2, 2, 3, 2),
                Stretch = Stretch.Uniform
            };
            i.SetValue(Grid.ColumnProperty, 0);
            if (myroConfig.IconFilePath != null)
                i.Source = new BitmapImage(new Uri("file://" + myroConfig.IconFilePath));

            s2.Children.Add(l1);
            s2.Children.Add(l2);
            s1.Children.Add(i);
            s1.Children.Add(s2);

            return s1;
        }
开发者ID:SamLin95,项目名称:cs3630,代码行数:43,代码来源:MyroConfig.cs

示例6: ScrollbackArea

        public ScrollbackArea(UserControl Parent)
        {
            _dock = new DockPanel();

            StackPanel sp = new StackPanel();
            sp.Orientation = Orientation.Horizontal;
            _dock.Children.Add(sp);

            sp.SetValue(DockPanel.DockProperty, Dock.Top);

            Button bCopyText = new Button();
            bCopyText.Content = "Copy Text To Clipboard";
            bCopyText.Click += new RoutedEventHandler(bCopyText_Click);
            sp.Children.Add(bCopyText);

            Button bSaveRtf = new Button();
            bSaveRtf.Content = "Save RTF";
            bSaveRtf.Click += new RoutedEventHandler(bSaveRtf_Click);
            sp.Children.Add(bSaveRtf);

            Button bSaveText = new Button();
            bSaveText.Content = "Save Text";
            bSaveText.Click += new RoutedEventHandler(bSaveText_Click);
            sp.Children.Add(bSaveText);

            ScrollViewer sv = new ScrollViewer();
            _dock.Children.Add(sv);

            _RTB = new RichTextBox();
            _RTB.IsReadOnly = true;
            _RTB.IsReadOnlyCaretVisible = true;

            _doc = new FlowDocument();
            _RTB.Document = _doc;

            _parent = Parent;

            Reset();

            sv.Content =_RTB;
        }
开发者ID:ChrisJamesSadler,项目名称:Cosmos,代码行数:41,代码来源:ScrollbackArea.cs

示例7: Button_Click

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Grid grid = new Grid();
            RowDefinition rowDefinition = new RowDefinition();
            rowDefinition.Height = GridLength.Auto;
            grid.RowDefinitions.Add(rowDefinition);
            grid.RowDefinitions.Add(new RowDefinition());

            StackPanel panel = new StackPanel();
            panel.Orientation = Orientation.Horizontal;
            panel.SetValue(Grid.RowProperty, 0);

            InsertButton("Print", btnPrint_Click, panel);
            InsertButton("Close", btnClose_Click, panel);

            grid.Children.Add(panel);
            
            XamlFormatProvider provider = new XamlFormatProvider();
            string documentContent = provider.Export(this.radRichTextBox.Document);

            RadRichTextBox rtb = new RadRichTextBox();
            rtb.Document = provider.Import(documentContent);
            rtb.IsReadOnly = true;
            rtb.IsFocusable = false;
            rtb.IsSelectionEnabled = false;
            rtb.IsContextMenuEnabled = false;
            rtb.IsSelectionMiniToolBarEnabled = false;
            rtb.SetValue(Grid.RowProperty, 1);

            grid.Children.Add(rtb);

            window.Height = 100;
            window.Width = 100;
            this.window.WindowState = WindowState.Maximized;
            this.window.Content = grid;
            this.window.Show();
        }
开发者ID:Motaz-Al-Zoubi,项目名称:xaml-sdk,代码行数:37,代码来源:MainPage.xaml.cs

示例8: LoadZoomIcons

        /// <summary>
        /// Load container for Zoom icons at the top-right corner of PlotArea
        /// </summary>
        protected void LoadZoomIcons()
        {
            _zoomIconContainer = new StackPanel();
            _zoomIconContainer.Orientation = Orientation.Horizontal;
            _zoomIconContainer.HorizontalAlignment = HorizontalAlignment.Right;
            _zoomIconContainer.VerticalAlignment = VerticalAlignment.Top;
            _zoomIconContainer.Margin = new Thickness(0, 3, 5, 0);
            _zoomIconContainer.SetValue(Canvas.ZIndexProperty, 95000);

            LoadZoomOutIcon();
            LoadSeparater();
            LoadShowAllIcon();

            _plotAreaGrid.Children.Add(_zoomIconContainer);
        }
开发者ID:zhangzy0193,项目名称:visifire,代码行数:18,代码来源:VisifireControl.cs

示例9: LoadToolBar

        /// <summary>
        /// Load ToolBar at the top-right side corner of the chart.
        /// </summary>
        protected void LoadToolBar()
        {
            _toolbarContainer = new StackPanel();
            _toolbarContainer.Orientation = Orientation.Horizontal;
            _toolbarContainer.HorizontalAlignment = HorizontalAlignment.Right;
            _toolbarContainer.VerticalAlignment = VerticalAlignment.Top;
            _toolbarContainer.Margin = new Thickness(0, 3, 5, 0);
            _toolbarContainer.SetValue(Canvas.ZIndexProperty, 90000);

            LoadWm();
            LoadSaveIcon();
            
            _rootElement.Children.Add(_toolbarContainer);
        }
开发者ID:zhangzy0193,项目名称:visifire,代码行数:17,代码来源:VisifireControl.cs

示例10: CreateLookBehindColumns

        /// <summary>
        /// Creates Look behind column.
        /// </summary>
        private void CreateLookBehindColumns()
        {
            if (this.lookBehindCellTemplate == null)
            {
                throw new ArgumentNullException("Look behind cell template must be defined", (Exception)null);
            }

            if (this.lookBehindSummaryCellTemplate == null)
            {
                throw new ArgumentNullException("Look behind summary cell template must be defined", (Exception)null);
            }

            this.lookBehindView = new LookBehindView();
            this.lookBehindColumn = new ColumnManager();
            Grid lookBehindLayout = DataTemplateHelper.LoadContent((this.layoutRoot.Resources["LookBehindCellTemplateGridLayout"] as DataTemplate)) as Grid;
            lookBehindLayout.SetValue(Grid.ColumnSpanProperty, this.WrapDataGridColumns.Count + 1);
            DataTemplate cellTemplate = this.layoutRoot.Resources["LookBehindCellTemplate"] as DataTemplate;
            StackPanel summaryPanel = new StackPanel();
            summaryPanel.SetValue(Grid.RowProperty, 0);
            summaryPanel.SetValue(Grid.ColumnProperty, 0);

            StackPanel columnPanel = new StackPanel();
            columnPanel.HorizontalAlignment = HorizontalAlignment.Right;
            columnPanel.Orientation = Orientation.Horizontal;
            columnPanel.SetValue(Grid.RowProperty, 0);
            columnPanel.SetValue(Grid.ColumnProperty, 1);

            SummaryManager summary = new SummaryManager();
            summary.CellTemplate = this.lookBehindSummaryCellTemplate;
            summary.MainPanel = summaryPanel;

            this.lookBehindColumn.SetValue(Grid.ColumnSpanProperty, 5);
            this.lookBehindColumn.MasterCellTemplate = cellTemplate;
            this.lookBehindColumn.CellTemplate = this.lookBehindCellTemplate;
            this.lookBehindColumn.StackPanel = columnPanel;
            this.lookBehindColumn.SummaryManager = summary;
            this.lookBehindColumn.GridLayout = lookBehindLayout;
        }
开发者ID:rbirkby,项目名称:mscui,代码行数:41,代码来源:WrapDataGrid.xaml.cs

示例11: Apply

        public void Apply()
        {
            panel.Children.RemoveRange(0, panel.Children.Count - 1);

            int i = 0;
            foreach (var language in Configuration.Languages.OrderBy(e => e.Culture.EnglishName))
            {
                var lang = language;
                var index = i++;
                var checkbox = new CheckBox();
                checkbox.IsChecked = lang.Enabled;
                checkbox.IsThreeState = false;
                checkbox.Content = lang.Culture.EnglishName;
                var delete = new Button();
                delete.Style = (Style)panel.Resources["ImageButton"];
                delete.Content = Image("Resources/cancel.gif", "Delete this language entry.");
                delete.Margin = new Thickness(0, 0, 8, 0);

                var stack = new StackPanel();
                stack.Orientation = Orientation.Horizontal;
                stack.Children.Add(delete);
                stack.Children.Add(checkbox);

                var defaultDict = new System.Windows.Controls.Primitives.ToggleButton();
                defaultDict.IsThreeState = false;
                if (!lang.HasStandardDictionary) defaultDict.Visibility = System.Windows.Visibility.Hidden;
                defaultDict.IsChecked = lang.CustomDictionaries.Contains("*");
                defaultDict.Content = Image("Resources/anchor.png", "Use the standard dictionary.");

                var customDict = new System.Windows.Controls.Primitives.ToggleButton();
                customDict.IsThreeState = false;
                customDict.IsChecked = lang.CustomDictionaries.Any(d => d != "*");
                customDict.Content = Image("Resources/book_open.png", "Use custom dictionaries.");

                var rightstack = new StackPanel();
                rightstack.Orientation = Orientation.Horizontal;
                rightstack.HorizontalAlignment = HorizontalAlignment.Right;
                rightstack.Children.Add(defaultDict);
                rightstack.Children.Add(customDict);

                var dock = new DockPanel();
                stack.SetValue(DockPanel.DockProperty, Dock.Left);
                rightstack.SetValue(DockPanel.DockProperty, Dock.Right);
                dock.Children.Add(stack);
                dock.Children.Add(rightstack);
                dock.Background = new SolidColorBrush(Color.FromRgb(0xff, 0xff, 0xff));
                dock.Opacity = 0.88;

                checkbox.Click += (sender, args) =>
                {
                    lang.Enabled = checkbox.IsChecked ?? false;
                };

                delete.Click += (sender, args) =>
                {
                    Configuration.Languages.Remove(lang);
                    panel.Children.Remove(dock);
                };

                defaultDict.Click += (sender, args) =>
                {
                    var has = lang.CustomDictionaries.Any(d => d == "*");
                    if (has != (defaultDict.IsChecked ?? false))
                    {
                        if (!has) lang.CustomDictionaries.Add("*");
                        else lang.CustomDictionaries.Remove("*");
                    }
                };

                customDict.Click += (sender, args) =>
                {
                    if (customDict.IsChecked ?? false)
                    {
                        // show file dialog to select custom dictionary files.
                        var d = new System.Windows.Forms.OpenFileDialog();
                        d.Title = "Select Custom Dictionary Files for " + lang.Culture.EnglishName;
                        d.SupportMultiDottedExtensions = true;
                        d.Multiselect = true;
                        d.Filter = "Dictionary Files (*.lex;*.txt;*.dic)|*.lex;*.txt;*.dic|All files (*.*)|*.*";
                        d.ShowDialog();
                        foreach (var file in d.FileNames)
                        {
                            var newfile = System.IO.Path.Combine(Configuration.ConfigDirectory, System.IO.Path.GetFileName(file));
                            var ext = System.IO.Path.GetExtension(file);
                            if (ext == ".dic")
                            { // import dic files from NetSpell & ISpell
                                newfile = Configuration.ImportDic(file);
                            } else
                            {
                                System.IO.File.Copy(file, newfile);
                            }
                            lang.CustomDictionaries.Add(System.IO.Path.GetFileName(newfile));
                        }
                    } else
                    {
                        foreach (var customd in lang.CustomDictionaries.Where(d => d != "*").ToList())
                        {
                            var file = System.IO.Path.Combine(Configuration.ConfigDirectory, customd);
                            if (File.Exists(file)) File.Delete(file);
                            lang.CustomDictionaries.Remove(customd);
//.........这里部分代码省略.........
开发者ID:simonegli8,项目名称:Spellchecker,代码行数:101,代码来源:AddRemoveWindow.xaml.cs

示例12: GetAllTimeHighCompleted

        private void GetAllTimeHighCompleted(object sender, GetHighscoresCompletedEventArgs e)
        {
            if (e.Result != null)
            {
                var grid = (Grid) _dialog.DialogContents.Content;
                var panel = new StackPanel();
                panel.SetValue(Grid.RowProperty, 0);
                panel.SetValue(Grid.ColumnProperty, 0);
                grid.Children.Add(panel);

                var header = new TextBlock
                                 {
                                     Style = Styles.StrongText,
                                     Margin = new Thickness(0, 0, 0, 5),
                                     Text = Strings.HighScoreAllTime
                                 };
                panel.Children.Add(header);

                int place = 1;
                foreach (DataItem score in e.Result)
                {
                    AddHighScore(panel, place, score.Name, score.Value);
                    place++;
                }
            }
            var statistics = new StatisticsClient();
            statistics.GetHighscoresCompleted += GetMonthHighCompleted;
            statistics.GetHighscoresAsync(Game.HighScore, new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1),
                                          null);
        }
开发者ID:lovlka,项目名称:cornball-silverlight,代码行数:30,代码来源:Main.xaml.cs

示例13: createGridLayout

        private Grid createGridLayout(double width, double height, out Grid grid, out TextBlock page)
        {
            grid=new Grid();
            Grid layout=new Grid();
            layout.VerticalAlignment = System.Windows.VerticalAlignment.Top;
            layout.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            layout.Width = width;
            layout.Height = width;
            layout.Children.Add(grid);
            grid.RowDefinitions.Add(new RowDefinition());
            grid.RowDefinitions.Add(new RowDefinition());
            grid.RowDefinitions.Add(new RowDefinition());
            grid.RowDefinitions[0].Height = new GridLength(50, GridUnitType.Pixel);
            grid.RowDefinitions[2].Height = new GridLength(15, GridUnitType.Pixel);
            grid.RowDefinitions[1].Height = new GridLength(height - 65, GridUnitType.Pixel);

            StackPanel headerPanel=new StackPanel();
            headerPanel.Height = 50;
            headerPanel.Background = new SolidColorBrush(Colors.LightGray);
            TextBlock header=new TextBlock();
            //header.Text = String.Format("{0} на {1}", GlobalStatus.Current.HomeHeader,DateTime.Now.ToString("dd.MM.yy HH:mm"));
            header.Text = "";
            header.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            header.FontSize = 13;
            headerPanel.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
            grid.Children.Add(headerPanel);
            headerPanel.Children.Add(header);
            headerPanel.SetValue(Grid.RowProperty, 0);

            //host.Measure(new Size(width, double.PositiveInfinity));

            Grid footerGrid=new Grid();
            footerGrid.Height = 15;
            footerGrid.Background = new SolidColorBrush(Colors.LightGray);
            footerGrid.ColumnDefinitions.Add(new ColumnDefinition());
            footerGrid.ColumnDefinitions.Add(new ColumnDefinition());
            footerGrid.ColumnDefinitions.Add(new ColumnDefinition());
            footerGrid.ColumnDefinitions[0].Width = GridLength.Auto;
            footerGrid.ColumnDefinitions[1].Width = new GridLength(1, GridUnitType.Star);
            footerGrid.ColumnDefinitions[2].Width = GridLength.Auto;
            footerGrid.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;

            TextBlock footer=new TextBlock();
            footer.Text = String.Format("{0} на {1} ", GlobalStatus.Current.HomeHeader, DateTime.Now.ToString("HH:mm")); ;
            footer.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            footer.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            footer.FontSize = 12;
            footerGrid.Children.Add(footer);
            footer.SetValue(Grid.ColumnProperty, 1);

            page=new TextBlock();
            page.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            page.TextAlignment = TextAlignment.Left;
            page.FontSize = 12;
            footerGrid.Children.Add(page);
            page.SetValue(Grid.ColumnProperty, 0);

            TextBlock podp=new TextBlock();
            podp.Text = String.Format("{0}",  DateTime.Now.ToString("dd.MM.yy"));
            podp.TextAlignment = TextAlignment.Right;
            podp.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            podp.FontSize = 12;
            footerGrid.Children.Add(podp);
            podp.SetValue(Grid.ColumnProperty, 2);

            grid.Children.Add(footerGrid);
            footerGrid.SetValue(Grid.RowProperty, 2);

            return layout;
        }
开发者ID:rj128x,项目名称:VotGESOrders,代码行数:70,代码来源:Home.xaml.cs

示例14: ImplantImage

		protected virtual void ImplantImage(double width, double height)
		{
			_img.Height = _editBox.ActualHeight;
			_img.Margin = _editBox.Margin;
			_img.Stretch = Stretch.Uniform;

			var parent = _editBox.Parent;

			var stackPanel = new StackPanel();
			stackPanel.Orientation = Orientation.Horizontal;
			stackPanel.Children.Add(_img);
			// stackPanel.Children.Add(_editBox); // this must be postponed here, since _editBox is still into the hierarchy

			if (parent is ContentControl)
			{
				((ContentControl)parent).Content = stackPanel;
			}
			else if (parent is Decorator)
			{
				((Decorator)parent).Child = stackPanel;
			}
			else if (parent is Panel)
			{
				var panel = (Panel)parent;
				var idx = panel.Children.IndexOf(_editBox);
				if (idx < 0)
					throw new InvalidOperationException(string.Format("The parent of the EditBox is a {0}, but the parent's children collection does not contain the EditBox", panel.GetType()));
				panel.Children.RemoveAt(idx);
				panel.Children.Insert(idx, stackPanel);
			}
			else
			{
				var stb = new StringBuilder();
				stb.AppendFormat("Unexpected location of the EditBox within {0}", this.ToString());
				stb.AppendLine();
				stb.AppendFormat("The parent of the editbox is {0}", _editBox.Parent.ToString());
				stb.AppendLine();
				stb.AppendLine("The hierarchy of childs is as follows:");
				PrintVisualChilds(this, 0, stb);
				throw new ApplicationException(stb.ToString());
			}

			stackPanel.Children.Add(_editBox);

			// now some special properties
			if (parent is Grid)
			{
				foreach (DependencyProperty dp in new DependencyProperty[] { Grid.RowProperty, Grid.ColumnProperty, Grid.RowSpanProperty, Grid.ColumnSpanProperty })
				{
					stackPanel.SetValue(dp, _editBox.GetValue(dp));
				}
			}
			if (parent is DockPanel)
			{
				stackPanel.SetValue(DockPanel.DockProperty, _editBox.GetValue(DockPanel.DockProperty));
			}

			/*

			if (_editBox.Parent is Grid) // most Windows version have the TextBox located inside a Grid
			{
				var grid = _editBox.Parent as Grid;
				_imgColumnDefinition = new ColumnDefinition();
				_imgColumnDefinition.Width = new GridLength(1, GridUnitType.Auto);
				grid.ColumnDefinitions.Insert(0, _imgColumnDefinition);
				foreach (UIElement ele in grid.Children)
				{
					if (ele is TextBox || ele is System.Windows.Controls.Primitives.ToggleButton)
					{
						ele.SetValue(Grid.ColumnProperty, 1 + (int)ele.GetValue(Grid.ColumnProperty));
					}
					else
					{
						ele.SetValue(Grid.ColumnSpanProperty, 1 + (int)ele.GetValue(Grid.ColumnSpanProperty));
					}
				}
				grid.Children.Add(_img);
			}
			else if (_editBox.Parent is DockPanel) // Some Windows XP versions have the TextBox sitting in a DockPanel instead of a Grid
			{
				var dockp = _editBox.Parent as DockPanel;
				var list = new List<UIElement>();
				foreach (UIElement child in dockp.Children) // collect the original children temporary in a list
					list.Add(child);

				dockp.Children.Clear(); // clear the children, because we need to dock them again

				_img.SetValue(DockPanel.DockProperty, Dock.Left);
				dockp.Children.Add(_img); // add the image to the left side
				foreach (UIElement child in list) // now dock the original children again
					dockp.Children.Add(child);
			}
			else
			{
				var stb = new StringBuilder();
				stb.AppendFormat("Unexpected location of grid within {0}", this.ToString());
				stb.AppendLine();
				stb.AppendFormat("The parent of the editbox is {0}", _editBox.Parent.ToString());
				stb.AppendLine();
				stb.AppendLine("The hierarchy of childs is as follows:");
//.........这里部分代码省略.........
开发者ID:Altaxo,项目名称:Altaxo,代码行数:101,代码来源:EditableImageComboBox.cs

示例15: CreateGroupingColumn

        /// <summary>
        /// Creates a grouping column.        
        /// </summary>
        private void CreateGroupingColumn()
        {
            ColumnManager column = new ColumnManager();

            // Load our cell template, then the ISV cell template and set grid column/row properties to isv cell template.
            DataTemplate cellTemplate = this.layoutRoot.Resources["GroupingColumnTemplate"] as DataTemplate;
            Grid headerTemplate = DataTemplateHelper.LoadContent(this.layoutRoot.Resources["GroupingHeaderTemplate"] as DataTemplate) as Grid;
            headerTemplate.SetValue(Grid.RowProperty, 1);
            headerTemplate.SetValue(Grid.ColumnProperty, 0);

            // Column manager stack panel.
            StackPanel columnStackPanel = new StackPanel();
            columnStackPanel.SetValue(Canvas.ZIndexProperty, 9999);
            columnStackPanel.SetValue(Grid.ColumnProperty, 0);
            columnStackPanel.SetValue(Grid.RowProperty, 4);

            // Set column manager properties.
            column.MasterCellTemplate = null;
            column.CellTemplate = cellTemplate;
            column.ColumnHeader = headerTemplate;
            column.StackPanel = columnStackPanel;

            // Add Column manager to column manager collection
            this.mainViewColumns.Add(column);
        }
开发者ID:rbirkby,项目名称:mscui,代码行数:28,代码来源:WrapDataGrid.xaml.cs


注:本文中的System.Windows.Controls.StackPanel.SetValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。