当前位置: 首页>>代码示例>>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;未经允许,请勿转载。