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


C# TextBlock.Arrange方法代码示例

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


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

示例1: GenerateTaskPanel

        /// <summary>
        ///     Generates a new task panel
        /// </summary>
        /// <param name="cl">Class to generate it for</param>
        /// <param name="parent">ListView associated with the class</param>
        /// <param name="task">Task to add</param>
        /// <returns>A new ListViewItem for the task</returns>
        public static ListViewItem GenerateTaskPanel(Class cl, ListView parent, Task task)
        {
            #region Containers

            // Create the content area
            Grid content = new Grid
            {
                Margin = new Thickness(0),
                Height = 75,
                Background = MainPage.LightGrayBrush,
                Tag = "Task"
            };

            // Create the list of content items and a delegate to add them to the list
            List<UIElement> contentItems = new List<UIElement>();
            Action<UIElement> registerItem = i => { contentItems.Add(i); };

            // The main ListViewItem
            ListViewItem panel = new ListViewItem
            {
                Background = MainPage.TransparentBrush,
                Margin = new Thickness(0, 0, 0, 5),
                Height = 75,
                Tag = false, // Is Panel Expanded
                HorizontalContentAlignment = HorizontalAlignment.Stretch,
                VerticalContentAlignment = VerticalAlignment.Top,
                Padding = new Thickness(0),
                BorderBrush = MainPage.MediumGrayBrush,
                BorderThickness = new Thickness(1),
            };

            #endregion

            #region Title

            // Task title
            TextBlock title = new TextBlock
            {
                Text = task.Title.Trim(),
                TextAlignment = TextAlignment.Left,
                FontSize = 25,
                Foreground = MainPage.BlueBrush,
                Margin = new Thickness(5, 0, 0, 0)
            };
            // Sizing
            title.Measure(new Size(0, 0));
            title.Arrange(new Rect(0, 0, 0, 0));
            registerItem(title);

            #endregion

            #region Finish Button

            // The check mark that marks the task as completed
            Button finish = new Button
            {
                FontFamily = Icons.IconFont,
                Content = task.Complete == 1 ? Icons.Cancel : Icons.Accept,
                Margin = new Thickness(title.ActualWidth + 5, 5, 0, 0),
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment = VerticalAlignment.Top,
                Background = MainPage.TransparentBrush
            };

            // Remove the task when the button is pressed
            finish.Tapped += (sender, args) => { TaskList.RemoveTask(cl, parent, panel, task); };
            registerItem(finish);

            #endregion

            #region Info Box

            // Info box
            TextBox info = new TextBox
            {
                TextAlignment = TextAlignment.Left,
                Foreground = new SolidColorBrush(Color.FromArgb(255, 50, 50, 50)),
                HorizontalAlignment = HorizontalAlignment.Left,
                TextWrapping = TextWrapping.Wrap,
                BorderThickness = new Thickness(0),
                AcceptsReturn = true,
                Width = parent.Width / 3 + 25,
                Tag = false, // Edit mode
                IsReadOnly = true, // Edit mode property
                Background = MainPage.TransparentBrush, // Edit mode property
                IsHitTestVisible = false // Edit mode property
            };

            // Add the text - only works if you append each character
            foreach (char c in task.Info)
            {
                info.Text += c.ToString();
            }
//.........这里部分代码省略.........
开发者ID:jkralicky,项目名称:TaskPlanner,代码行数:101,代码来源:TaskPanelFactory.cs

示例2: BlockHeightOf

        private double BlockHeightOf( TextBlock t )
        {
            t.Measure( new Size( double.PositiveInfinity, double.PositiveInfinity ) );
            t.Arrange( new Rect( new Point(), t.DesiredSize ) );

            /* INTENSIVE_LOG
            if( t.FontSize == 16 )
            {
                Logger.Log( ID, string.Format( "FontSize 16 detected {0}, Should be {1}. Text {2}", t.FontSize, FontSize, t.Text ), LogType.DEBUG );
            }
            //*/

            return t.ActualHeight;
        }
开发者ID:tgckpg,项目名称:libpenguin,代码行数:14,代码来源:VerticalStack.cs


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