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


C# TextBlock.SetBinding方法代码示例

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


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

示例1: Comment

        public Comment(Node hostNode)
        {
            HostNode = hostNode;

            var scrollViewer = new ScrollViewer
            {
                HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled,
                VerticalScrollBarVisibility = ScrollBarVisibility.Visible,
                Height = 70,
                CanContentScroll = true
            };

            var textBlock = new TextBlock
            {
                Background = Brushes.Transparent,
                TextWrapping = TextWrapping.Wrap,
                Margin = new Thickness(5),
                FontSize = 12
            };

            Child = scrollViewer;
            CornerRadius = new CornerRadius(5);
            scrollViewer.Content = textBlock;


            var bindingTextToTextBlock = new Binding("Text")
            {
                Source = this,
                Mode = BindingMode.OneWay
            };
            textBlock.SetBinding(TextBlock.TextProperty, bindingTextToTextBlock);

            hostNode.SpaceCanvas.Children.Add(this);
        }
开发者ID:bsudhakarGit,项目名称:TUM.CMS.VPLControl,代码行数:34,代码来源:Comment.cs

示例2: StockFinancialUserControl

        public StockFinancialUserControl()
        {
            InitializeComponent();

            foreach (var prop in (typeof(StockFinancial)).GetProperties())
            {
                if (prop.PropertyType == typeof(DataTable) || prop.PropertyType.Name.StartsWith("List"))
                    continue;
                StackPanel propertyRow = new StackPanel() { Orientation = Orientation.Horizontal };

                // Create financials control
                Label labelTitle = new Label();
                labelTitle.Content = prop.Name;
                labelTitle.Width = 100;

                TextBlock labelValue = new TextBlock();
                labelValue.Margin = new Thickness(0, 5, 0, 0);
                if (prop.Name == "Yield")
                {
                    labelValue.SetBinding(TextBlock.TextProperty, new Binding(prop.Name) { StringFormat = "P2" });
                }
                else
                {
                    labelValue.SetBinding(TextBlock.TextProperty, new Binding(prop.Name));
                }
                propertyRow.Children.Add(labelTitle);
                propertyRow.Children.Add(labelValue);

                this.propertyPanel.Children.Add(propertyRow);
            }
        }
开发者ID:dadelcarbo,项目名称:StockAnalyzer,代码行数:31,代码来源:StockFinancialUserControl.xaml.cs

示例3: AddTextBlocks

        private void AddTextBlocks( )
        {
            _textBlocks = new TextBlock[App.GameModel.Columns, App.GameModel.Rows];
            for(var i = 0; i < App.GameModel.Rows; i++)
            {
                for(var j = 0; j < App.GameModel.Columns; j++)
                {
                    var b = new Border {Style = (Style) Application.Current.Resources["BorderStyle"] };
                    var t = new TextBlock();


                    t.Drop += TextBlock_Drop;
                    t.Style = (Style)Application.Current.Resources["GameBoardTBlockStyle"];
                    b.Child = t;

                    string s = $"App.GameModel.GameBoard[{j},{i}]";
                    var textBinding = new Binding(s);
                    //textBinding.Source = App.GameModel;
                    t.SetBinding(TextBlock.TextProperty, textBinding);

                    var colorBinding = new Binding("AllowDrop")
                    {
                        Source = t,
                        Converter = new BoolToColorConverter()
                    };
                    t.SetBinding(TextBlock.BackgroundProperty, colorBinding);
                    Grid.SetRow(b, i);
                    Grid.SetColumn(b, j);
                    _textBlocks[j, i] = t;
                    GameBoard.Children.Add(b);
                }
            }
        }
开发者ID:Chr1st1anSzech,项目名称:Wortspiel,代码行数:33,代码来源:MainWindow.xaml.cs

示例4: ImageButton

        /// <summary>
        /// Initializes a new instance of the <see cref="ImageButton"/> class.
        /// </summary>
        public ImageButton()
        {
            SetResourceReference(HeightProperty, "DefaultControlHeight");

            var panel = new StackPanel {Orientation = Orientation.Horizontal};

            _icon = new Image {Margin = new Thickness(0, 0, 6, 0)};
            var imageBinding = new Binding("Icon")
                               	{
                               		Source = this,
                               		UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
                               	};
            _icon.SetBinding(Image.SourceProperty, imageBinding);

            panel.Children.Add(_icon);

            _textBlock = new TextBlock();
            var textBinding = new Binding("Content")
                              	{
                              		Source = this,
                              		UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
                              	};
            _textBlock.SetBinding(TextBlock.TextProperty, textBinding);
            panel.Children.Add(_textBlock);

            base.Content = panel;

            SetResourceReference(StyleProperty, typeof (Button));
        }
开发者ID:StevenThuriot,项目名称:Nova,代码行数:32,代码来源:ImageButton.cs

示例5: kmllayer_Initialized

        void kmllayer_Initialized(object sender, System.EventArgs e)
        {
            foreach (Layer layer in (sender as KmlLayer).ChildLayers)
            {
                layer.Visible = true;

                Border border = new Border()
                {
                    Background = new SolidColorBrush(Colors.White),
                    BorderBrush = new SolidColorBrush(Colors.Black),
                    BorderThickness = new Thickness(1),
                    CornerRadius = new CornerRadius(5)
                };

                StackPanel stackPanelChild = new StackPanel()
                {
                    Orientation = Orientation.Horizontal,
                    Margin = new Thickness(5)
                };

                TextBlock textValue = new TextBlock();
                Binding valueBinding = new Binding(string.Format("[{0}]", "name"));
                textValue.SetBinding(TextBlock.TextProperty, valueBinding);

                stackPanelChild.Children.Add(textValue);

                border.Child = stackPanelChild;
                (layer as KmlLayer).MapTip = border;
            }
        }
开发者ID:ealvarezp,项目名称:arcgis-samples-silverlight,代码行数:30,代码来源:WebMapKML.xaml.cs

示例6: Send

        /// <summary>
        /// Add a new message to the subtopic box
        /// </summary>
        /// <param name="message"></param>
        public void Send(Message message)
        {
            Messages.Add(message);

            // Create the textblock control
            TextBlock visualMessage = new TextBlock();
            visualMessage.TextWrapping = TextWrapping.Wrap;
            visualMessage.Text = message.Text;
            visualMessage.DataContext = Contents;

            // Set width databinding for 
            var widthBinding = new Binding("ActualWidth");
            widthBinding.Source = Content;
            widthBinding.Mode = BindingMode.OneWay;
            visualMessage.SetBinding(TextBlock.MaxWidthProperty, widthBinding);

            if (message.Sender == MessageSender.Ai)
            {
                // AI messages are displayed in bold type
                visualMessage.FontWeight = FontWeights.Bold;
            }
            else
            {
                // User messages are displayed with a prompt character,
                // and in italic type
                visualMessage.Text = " > " + visualMessage.Text;
                visualMessage.FontStyle = FontStyles.Oblique;
            }

            Contents.Children.Add(visualMessage);
        }
开发者ID:carsonmyers,项目名称:Armchair-Intellectual,代码行数:35,代码来源:SubtopicBox.xaml.cs

示例7: UIBoundToCustomerWithNesting

        public UIBoundToCustomerWithNesting()
        {
            var stack = new StackPanel();
            Content = stack;

            var textBlock = new TextBlock();
            textBlock.SetBinding(TextBlock.TextProperty, new Binding("FirstName"));
            stack.Children.Add(textBlock);

            textBlock = new TextBlock();
            textBlock.SetBinding(TextBlock.TextProperty, new Binding("LastName"));
            stack.Children.Add(textBlock);

            var addressStack = new StackPanel();
            stack.Children.Add(addressStack);

            textBlock = new TextBlock();
            textBlock.SetBinding(TextBlock.TextProperty, new Binding("MailingAddress.Street")); //misspelling
            addressStack.Children.Add(textBlock);

            textBlock = new TextBlock();
            textBlock.SetBinding(TextBlock.TextProperty, new Binding("MailingAddress.City"));
            addressStack.Children.Add(textBlock);

            textBlock = new TextBlock();
            textBlock.SetBinding(TextBlock.TextProperty, new Binding("BllingAddress.Street2")); //misspelling
            addressStack.Children.Add(textBlock);
        }
开发者ID:ssethi,项目名称:TestFrameworks,代码行数:28,代码来源:UIBoundToCustomerWithNesting.cs

示例8: SimpleUIBoundToCustomer

        public SimpleUIBoundToCustomer()
        {
            var stack = new StackPanel();
            Content = stack;

            var textBlock = new TextBlock();
            textBlock.SetBinding(TextBlock.TextProperty, new Binding("FirstName"));
            stack.Children.Add(textBlock);

            textBlock = new TextBlock();
            textBlock.SetBinding(TextBlock.TextProperty, new Binding("LstName")); //purposefully misspelled
            stack.Children.Add(textBlock);

            textBlock = new TextBlock();
            textBlock.SetBinding(TextBlock.TextProperty, new Binding()); //context
            stack.Children.Add(textBlock);

            var checkbox = new CheckBox();
            checkbox.SetBinding(CheckBox.IsCheckedProperty, new Binding("asdfsdf")); //does not exist
            stack.Children.Add(checkbox);

            var tooltip = new ToolTip();
            tooltip.SetBinding(System.Windows.Controls.ToolTip.ContentProperty, new Binding("asdfasdasdf")); // does not exist
            stack.ToolTip = tooltip;

            var childUserControl = new SimpleUIBoundToCustomerByAttachedPorperty();
            stack.Children.Add(childUserControl);
        }
开发者ID:ssethi,项目名称:TestFrameworks,代码行数:28,代码来源:SimpleUIBoundToCustomer.cs

示例9: CreateCellElement

        public override FrameworkElement CreateCellElement(GridViewCell cell, object dataItem)
        {
            TextBlock tb = new TextBlock();
            tb.SetBinding(TextBlock.TextProperty, new Binding(this.DataMemberBinding.Path.Path) { Converter = new MyConverter() });

            return tb;
        }
开发者ID:Motaz-Al-Zoubi,项目名称:xaml-sdk,代码行数:7,代码来源:CustomColumn.cs

示例10: BuildElement

        public FrameworkElement BuildElement()
        {
            var panel = new StackPanel();
            panel.Orientation = Orientation.Horizontal;
            panel.Margin = new Thickness(2);

            var textBlock = new TextBlock();
            textBlock.SetBinding(TextBlock.TextProperty, new Binding(bindingPath));
            textBlock.Margin = new Thickness(0,0,2,0);

            var button = new Button();
            var source = new BitmapImage();

            var uri1 = new Uri("pack://application:,,,/Commons.UI.WPF;component/Images/binary.png", UriKind.Absolute);
            source.BeginInit();
            source.UriSource = uri1;
            source.EndInit();

            var image = new Image()
                          	{
                          		Source = source,
                          		Width = 16
                          	};

            button.Content = image;
            button.Click += ShowBinaryViewer;

            panel.Children.Add(textBlock);
            panel.Children.Add(button);
            return panel;
        }
开发者ID:vansickle,项目名称:dbexplorer,代码行数:31,代码来源:DataGridBinaryColumn.xaml.cs

示例11: UIBoundToCustomerWithItemsControl

        public UIBoundToCustomerWithItemsControl()
        {
            var stack = new StackPanel();
            Content = stack;

            var textBlock = new TextBlock();
            textBlock.SetBinding(TextBlock.TextProperty, new Binding("FirstName"));
            stack.Children.Add(textBlock);

            textBlock = new TextBlock();
            textBlock.SetBinding(TextBlock.TextProperty, new Binding("LastName"));
            stack.Children.Add(textBlock);

            var addressStack = new StackPanel();
            stack.Children.Add(addressStack);

            textBlock = new TextBlock();
            textBlock.SetBinding(TextBlock.TextProperty, new Binding("MailingAddress.Street")); //misspelling
            addressStack.Children.Add(textBlock);

            textBlock = new TextBlock();
            textBlock.SetBinding(TextBlock.TextProperty, new Binding("MailingAddress.City"));
            addressStack.Children.Add(textBlock);

            textBlock = new TextBlock();
            textBlock.SetBinding(TextBlock.TextProperty, new Binding("BllingAddress.Street2")); //misspelling
            addressStack.Children.Add(textBlock);

            var listBox = new ListBox {ItemTemplate = CreateItemTemplate()};
            listBox.SetBinding(ListBox.ItemsSourceProperty, new Binding("Orders"));
            stack.Children.Add(listBox);
        }
开发者ID:ssethi,项目名称:TestFrameworks,代码行数:32,代码来源:UIBoundToCustomerWithItemsControl.cs

示例12: CreateFallbackRoot

		internal static Grid CreateFallbackRoot ()
		{
			Grid grid = new Grid ();
			TextBlock block = new TextBlock ();
			block.SetBinding (TextBlock.TextProperty, new Binding ());
			grid.Children.Add (block);
			return grid;
		}
开发者ID:shana,项目名称:moon,代码行数:8,代码来源:ContentControl.cs

示例13: GenerateElement

        protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem)
        {
            TextBlock cellElement = new TextBlock();

            System.Windows.Data.Binding textBinding = new System.Windows.Data.Binding(cell.Column.Header + ".DisplayValue")
                                                          {Source = dataItem};
            cellElement.SetBinding(TextBlock.TextProperty, textBinding);

            System.Windows.Data.Binding backgroundBinding = new System.Windows.Data.Binding(cell.Column.Header + ".Background")
                                                                {Source = dataItem};
            cellElement.SetBinding(TextBlock.BackgroundProperty, backgroundBinding);

            System.Windows.Data.Binding foreGroundBinding = new System.Windows.Data.Binding(cell.Column.Header + ".Foreground")
                                                                {Source = dataItem};
            cellElement.SetBinding(TextBlock.ForegroundProperty, foreGroundBinding);

            return cellElement;
        }
开发者ID:nagyist,项目名称:wpfrealtime,代码行数:18,代码来源:WpfGridColumn.cs

示例14: GenerateElement

        protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem)
        {
            var binding = new Binding(bindingPath);

            var textBlock = new TextBlock();
            textBlock.SetBinding(TextBlock.TextProperty, binding);
            textBlock.Margin = new Thickness(0, 0, 2, 0);

            return BuildElement(textBlock);
        }
开发者ID:vansickle,项目名称:dbexplorer,代码行数:10,代码来源:DataGridDateTimeColumn.xaml.cs

示例15: GetGeneratedContent

        /// <summary>
        /// Generate content for cell by column binding
        /// </summary>
        /// <returns>TextBlock element</returns>
        internal override FrameworkElement GetGeneratedContent()
        {
            TextBlock result = new TextBlock();

            if (this.Binding != null)
            {
                result.SetBinding(TextBlock.TextProperty, this.Binding);
            }

            return result;
        }
开发者ID:AlexanderShniperson,项目名称:GridView4WP7,代码行数:15,代码来源:GridViewTextColumn.cs


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