當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。