當前位置: 首頁>>代碼示例>>C#>>正文


C# Controls.TextBlock類代碼示例

本文整理匯總了C#中System.Windows.Controls.TextBlock的典型用法代碼示例。如果您正苦於以下問題:C# TextBlock類的具體用法?C# TextBlock怎麽用?C# TextBlock使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


TextBlock類屬於System.Windows.Controls命名空間,在下文中一共展示了TextBlock類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: PageHeader

        public PageHeader()
        {
            Brush brush = new SolidColorBrush(Colors.DarkGray);
            brush.Opacity = 0.60;

            this.Background = brush;

            Border frameBorder = new Border();
            frameBorder.BorderBrush = Brushes.Gray;
            frameBorder.BorderThickness = new Thickness(2);

            DockPanel panelMain = new DockPanel();
            panelMain.Margin = new Thickness(5, 5, 5, 5);
            panelMain.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;

            txtText = new TextBlock();
            txtText.FontSize = 32;
            txtText.Margin = new Thickness(5, 0, 0, 0);
            txtText.SetResourceReference(TextBlock.ForegroundProperty, "HeaderTextColor");
            txtText.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;

            panelMain.Children.Add(txtText);

            frameBorder.Child = panelMain;

            this.Content = frameBorder;
        }
開發者ID:rhgtvcx,項目名稱:tap-desktop,代碼行數:27,代碼來源:PageHeader.cs

示例2: Game

        public Game(UserControl userControl, Canvas drawingCanvas, Canvas debugCanvas, TextBlock txtDebug)
        {
            //Initialize
            IsActive = true;
            IsFixedTimeStep = true;
            TargetElapsedTime = new TimeSpan(0, 0, 0, 0, 16);
            Components = new List<DrawableGameComponent>();
            World = new World(new Vector2(0, 0));
            _gameTime = new GameTime();
            _gameTime.GameStartTime = DateTime.Now;
            _gameTime.FrameStartTime = DateTime.Now;
            _gameTime.ElapsedGameTime = TimeSpan.Zero;
            _gameTime.TotalGameTime = TimeSpan.Zero;

            //Setup Canvas
            DrawingCanvas = drawingCanvas;
            DebugCanvas = debugCanvas;
            TxtDebug = txtDebug;
            UserControl = userControl;

            //Setup GameLoop
            _gameLoop = new Storyboard();
            _gameLoop.Completed += GameLoop;
            _gameLoop.Duration = TargetElapsedTime;
            DrawingCanvas.Resources.Add("gameloop", _gameLoop);
        }
開發者ID:hilts-vaughan,項目名稱:Farseer-Physics,代碼行數:26,代碼來源:Game.cs

示例3: ExamineKeystrokes

        public ExamineKeystrokes()
        {
            Title = "Examine Keystrokes";
            FontFamily = new FontFamily("Courier New");

            Grid grid = new Grid();
            Content = grid;

            // Make one row "auto" and the other fill the remaining space.
            RowDefinition rowdef = new RowDefinition();
            rowdef.Height = GridLength.Auto;
            grid.RowDefinitions.Add(rowdef);
            grid.RowDefinitions.Add(new RowDefinition());

            // Display header text.
            TextBlock textHeader = new TextBlock();
            textHeader.FontWeight = FontWeights.Bold;
            textHeader.Text = strHeader;
            grid.Children.Add(textHeader);

            // Create StackPanel as child of ScrollViewer for displaying events.
            scroll = new ScrollViewer();
            grid.Children.Add(scroll);
            Grid.SetRow(scroll, 1);

            stack = new StackPanel();
            scroll.Content = stack;
        }
開發者ID:gawallsibya,項目名稱:BIT_MFC-CShap-DotNet,代碼行數:28,代碼來源:ExamineKeystrokes.cs

示例4: 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

示例5: Create

        public static Uri Create(string filename, string text, SolidColorBrush backgroundColor, double textSize, Size size)
        {
            var background = new Rectangle();
            background.Width = size.Width;
            background.Height = size.Height;
            background.Fill = backgroundColor;

            var textBlock = new TextBlock();
            textBlock.Width = 500;
            textBlock.Height = 500;
            textBlock.TextWrapping = TextWrapping.Wrap;
            textBlock.Text = text;
            textBlock.FontSize = textSize;
            textBlock.Foreground = new SolidColorBrush(Colors.White);
            textBlock.FontFamily = new FontFamily("Segoe WP");

            var tileImage = "/Shared/ShellContent/" + filename;
            using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication())
            {
                var bitmap = new WriteableBitmap((int)size.Width, (int)size.Height);
                bitmap.Render(background, new TranslateTransform());
                bitmap.Render(textBlock, new TranslateTransform() { X = 39, Y = 88 });
                var stream = store.CreateFile(tileImage);
                bitmap.Invalidate();
                bitmap.SaveJpeg(stream, (int)size.Width, (int)size.Height, 0, 99);
                stream.Close();
            }
            return new Uri("ms-appdata:///local" + tileImage, UriKind.Absolute);
        }
開發者ID:halllo,項目名稱:DailyQuote,代碼行數:29,代碼來源:LockScreenImage.cs

示例6: MainTab

 public MainTab(int page, TabItem newTab, Image newVerso, Image newRecto, Grid canvas, Grid vGrid, Grid rGrid, Button delBtn, ScatterView SV, ScatterViewItem si, Grid vSwipeGrid, Grid rSwipeGrid, Grid vTranslationGrid, Grid rTranslationGrid, Grid vBoxesGrid, Grid rBoxesGrid, TextBlock headerText, SurfaceWindow1.language language)
 {
     _page = page;
     _tab = newTab;
     _verso = newVerso;
     _recto = newRecto;
     _canvas = canvas;
     _vGrid = vGrid;
     _rGrid = rGrid;
     _SVI = si;
     _delButton = delBtn;
     numFingersRecto = 0;
     numFingersVerso = 0;
     fingerPos = new List<Point>();
     avgTouchPoint = new Point(-1, 0);
     _vSwipeGrid = vSwipeGrid;
     _rSwipeGrid = rSwipeGrid;
     _vTranslationGrid = vTranslationGrid;
     _rTranslationGrid = rTranslationGrid;
     _vBoxesGrid = vBoxesGrid;
     _rBoxesGrid = rBoxesGrid;
     _twoPage = true;
     _SV = SV;
     _headerTB = headerText;
     _currentLanguage = language;
     _previousLanguage = _currentLanguage;
     _worker = new Workers(this);
 }
開發者ID:straboulsi,項目名稱:fauvel,代碼行數:28,代碼來源:Tab.cs

示例7: UserControl_DataContextChanged

        private void UserControl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            var selectedItem = (DataContext as IEntityGridViewModel).SelectedItem;

            if (selectedItem == null)
                return;

                Type type = selectedItem.GetType();
            var relationshipProperties = type.GetProperties()
             .Where(t =>
                     t.Name != "Relationships" &&
                     t.GetGetMethod().IsVirtual &&
                     t.PropertyType.IsGenericType &&
                     t.PropertyType.GetGenericTypeDefinition() == typeof(ICollection<>))
             .ToList();

            foreach (var property in relationshipProperties)
            {
                //Binding binding = new Binding() { Path = new PropertyPath("SelectedItem." + property.Name), Source = this.DataContext };

                TextBlock textBlock = new TextBlock() { Text = property.Name };
                //BindingOperations.SetBinding(textBlock, TextBlock.TextProperty, binding);

                relatedEntitiesStackPanel.Children.Add(textBlock);

                Binding binding = new Binding() { Path = new PropertyPath("SelectedItem." + property.Name), Source = this.DataContext };

                DataGridControl listView = new DataGridControl();
                var value = property.GetValue(selectedItem) as System.Collections.IEnumerable;
                //listView.ItemsSource = value;
                BindingOperations.SetBinding(listView, DataGrid.ItemsSourceProperty, binding);

                relatedEntitiesStackPanel.Children.Add(listView);
            }
        }
開發者ID:jweimann,項目名稱:webdb,代碼行數:35,代碼來源:RelatedEntitiesView.xaml.cs

示例8: AttachControl

        public override bool AttachControl(FilterPropertiesControl control)
        {
            Control = control;

            Grid grid = new Grid();
            int rowIndex = 0;

            TextBlock brightnessText = new TextBlock();
            brightnessText.Text = "Threshold";
            Grid.SetRow(brightnessText, rowIndex++);

            Slider brightnessSlider = new Slider();
            brightnessSlider.Minimum = 0.0;
            brightnessSlider.Maximum = 1.0;
            brightnessSlider.Value = _colorSwapFilter.Threshold;
            brightnessSlider.ValueChanged += brightnessSlider_ValueChanged;
            Grid.SetRow(brightnessSlider, rowIndex++);


            for (int i = 0; i < rowIndex; ++i)
            {
                RowDefinition rd = new RowDefinition();
                grid.RowDefinitions.Add(rd);
            }

            grid.Children.Add(brightnessText);
            grid.Children.Add(brightnessSlider);

            control.ControlsContainer.Children.Add(grid);

            return true;
        }
開發者ID:sachin4203,項目名稱:ClassicPhotoEditor,代碼行數:32,代碼來源:MynewFilter3.cs

示例9: GenerateTextBlock

 private TextBlock GenerateTextBlock()
 {
     TextBlock textBlock = new TextBlock();
     textBlock.TextWrapping = TextWrapping.Wrap;
     textBlock.Margin = new Thickness(10);
     return textBlock;
 }
開發者ID:g360230,項目名稱:quran-phone,代碼行數:7,代碼來源:TextBlockSplitter.cs

示例10: SetEvidence

        internal void SetEvidence(
            IDictionary<string, Tuple<FObservation, FRandomVariable[]>> evidences,
            IDictionary<string, string> abbreviations)
        {
            var evidencesSorted
                = evidences.OrderBy(kvp => kvp.Key);

            xEvidenceList.Children.Clear();

            foreach (var kvp in evidencesSorted)
            {
                // Scenario label.
                TextBlock scenarioLabel = new TextBlock();
                scenarioLabel.Text = kvp.Key;
                xEvidenceList.Children.Add(scenarioLabel);

                // Observation values.
                Observation.Observation obsControl = new Observation.Observation();
                var observation = kvp.Value.Item1;
                var observationVariables = kvp.Value.Item2;
                obsControl.SetData(observation, observationVariables, abbreviations);
                xEvidenceList.Children.Add(obsControl);
                obsControl.Margin = new Thickness(0, 0, 0, 12);
            }
        }
開發者ID:duckmaestro,項目名稱:F-AI,代碼行數:25,代碼來源:EvidenceInspector.xaml.cs

示例11: MakeGivenGrid

        protected override Grid MakeGivenGrid()
        {
            //Set up grid
            Grid grid = new Grid();
            grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
            grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
            grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });

            //Create the description text
            TextBlock desc = new TextBlock();
            desc.TextWrapping = TextWrapping.Wrap;
            desc.Text = "Specify a midpoint.";
            desc.Margin = new Thickness(0, 0, 0, 10);

            //Create a combo box to choose from
            optionsBox = new ComboBox();
            optionsBox.MinWidth = 200;

            //Align elements in grid and add them to it
            Grid.SetColumn(desc, 0);
            Grid.SetRow(desc, 0);
            grid.Children.Add(desc);
            Grid.SetColumn(optionsBox, 0);
            Grid.SetRow(optionsBox, 1);
            grid.Children.Add(optionsBox);

            return grid;
        }
開發者ID:wcatykid,項目名稱:GeoShader,代碼行數:28,代碼來源:AddMidpoint.cs

示例12: ExtTreeNode

        public ExtTreeNode(Image icon, string title)
            : this()
        {
            if (icon != null)
            {
                this.icon = icon;
            }
            else//test inti icon
            {
                this.icon = new Image();
                BitmapImage bitmapImage = new BitmapImage();
                bitmapImage.BeginInit();
                bitmapImage.UriSource = new Uri(@"pack://application:,,,/ATNET;component/icons/add.png", UriKind.RelativeOrAbsolute);
                //bitmapImage.UriSource = new Uri(@"../../icons/add.png", UriKind.RelativeOrAbsolute);
                bitmapImage.EndInit();
                this.icon.Source = bitmapImage;
            }

            this.icon.Width = 16;
            this.icon.Height = 16;

            this.title = title;

            TextBlock tb = new TextBlock();
            tb.Text = title;
            Grid grid = new Grid();
            grid.ColumnDefinitions.Add(new ColumnDefinition());
            grid.ColumnDefinitions.Add(new ColumnDefinition());
            grid.Children.Add(this.icon);
            grid.Children.Add(tb);
            Grid.SetColumn(this.icon, 0);
            Grid.SetColumn(tb, 1);
            this.Header = grid;
        }
開發者ID:ichengzi,項目名稱:atnets,代碼行數:34,代碼來源:ExtTreeNode.cs

示例13: OnApplyTemplate

    public override void OnApplyTemplate()
    {
        if (MapDetailsControl != null)
        {
            MapDetailsControl.MapDetailsChanged -= RaiseMapDetailsChanged;
            MapDetailsControl.MapSelectedForOpening -= RaiseMapSelectedForOpening;
        }

        if (ResultsListBox != null)
            ResultsListBox.SelectionChanged -= ResultListBox_SelectionChanged;

        base.OnApplyTemplate();

        MapDetailsControl = GetTemplateChild("MapDetailsControl") as MapDetailsControl;
        ResultsListBox = GetTemplateChild("ResultsListBox") as ListBox;
        SearchResultsTextBlock = GetTemplateChild("SearchResultsTextBlock") as TextBlock;
        DataPager = GetTemplateChild("DataPager") as DataPager;

        if (MapDetailsControl != null)
        {
            MapDetailsControl.MapDetailsChanged += RaiseMapDetailsChanged;
            MapDetailsControl.MapSelectedForOpening += RaiseMapSelectedForOpening;
        }

        if (ResultsListBox != null)
        {
            ResultsListBox.SelectionChanged += ResultListBox_SelectionChanged;
            ResultsListBox.DataContext = this;
        }
        if (_isDirty)
            GenerateResults();
    }
開發者ID:Esri,項目名稱:arcgis-viewer-silverlight,代碼行數:32,代碼來源:MyMapsControl.xaml.cs

示例14: setChoices

        public void setChoices(List<string> choices)
        {
            TextBlock txtBlock;
            
            if (choices == null || choices.Count == 0)
            {
                return;
            }

            choicesList = choices;
            listBox.Items.Clear();

            foreach (string str in choices)
            {
                txtBlock = new TextBlock();

                txtBlock.TextWrapping = TextWrapping.Wrap;
                txtBlock.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
                txtBlock.Width = 370;
                txtBlock.Text = str;
                txtBlock.Margin = new Thickness(0, 2, 0, 2);

                listBox.Items.Add(txtBlock);
            }

            //listBox.ItemsSource = choices;
        }
開發者ID:rokuan,項目名稱:iris,代碼行數:27,代碼來源:MenuBox.xaml.cs

示例15: Button_Loaded

 private void Button_Loaded(object sender, RoutedEventArgs args)
 {
     System.Windows.Controls.Button button = sender as System.Windows.Controls.Button;
     if (button != null)
     {
         StackPanel panel = new StackPanel()
         {
             Orientation = Orientation.Horizontal
         };
         Image shield = new Image()
         {
             Width = 24,
             Source = Shield
         };
         panel.Children.Add(shield);
         Rectangle rect = new Rectangle()
         {
             Width = 10
         };
         panel.Children.Add(rect);
         TextBlock text = new TextBlock()
         {
             Text = (button.Command as RoutedUICommand).Text
         };
         panel.Children.Add(text);
         button.Content = panel;
     }
 }
開發者ID:Qibbi,項目名稱:OpenSAGE,代碼行數:28,代碼來源:ButtonElevated.xaml.cs


注:本文中的System.Windows.Controls.TextBlock類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。