本文整理汇总了C#中System.Windows.Controls.TextBlock.InvalidateMeasure方法的典型用法代码示例。如果您正苦于以下问题:C# TextBlock.InvalidateMeasure方法的具体用法?C# TextBlock.InvalidateMeasure怎么用?C# TextBlock.InvalidateMeasure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.TextBlock
的用法示例。
在下文中一共展示了TextBlock.InvalidateMeasure方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RecreateInlines
private static void RecreateInlines(TextBlock t, Inline prefix, IEnumerable<Inline> list)
{
t.Inlines.Clear();
if (prefix != null)
t.Inlines.Add(prefix);
foreach (var i in list)
{
t.Inlines.Add(i);
}
t.InvalidateMeasure();
}
示例2: ArrangeTooLongLocal_LineWrapMeasureReverseTest
public void ArrangeTooLongLocal_LineWrapMeasureReverseTest ()
{
Border b = new Border ();
TextBlock tb = new TextBlock ();
tb.TextWrapping = TextWrapping.Wrap;
b.Child = tb;
tb.Width = 44;
tb.Text = "Hello and don't you forget Who I am";
Assert.IsTrue (tb.ActualWidth > 32 && tb.ActualWidth < 34, "1. textblock.ActualWidth is " + tb.ActualWidth.ToString ());
Assert.AreEqual (7, GetLineCount (tb.ActualHeight), "1. line count based on textblock.ActualHeight");
//Assert.AreEqual (112, tb.ActualHeight, "1. tb.ActualHeight");
//Console.WriteLine ("=========== Calling Border.Measure() ============");
b.Measure (new Size (Double.PositiveInfinity, Double.PositiveInfinity));
//Console.WriteLine ("========= Done calling Border.Measure() =========");
// FIXME: wrong after this point
Assert.IsTrue (tb.ActualWidth < 10.9 && tb.ActualWidth > 10.8, "2. textblock.ActualWidth is " + tb.ActualWidth.ToString ());
Assert.AreEqual (28, GetLineCount (tb.ActualHeight), "2. line count based on textblock.ActualHeight");
//Assert.AreEqual (560, tb.ActualHeight, "2. tb.ActualHeight");
tb.Text = "Hello and don't you forget Who I am.";
Assert.IsTrue (tb.ActualWidth < 10.9 && tb.ActualWidth > 10.8, "3. textblock.ActualWidth is " + tb.ActualWidth.ToString ());
Assert.AreEqual (29, GetLineCount (tb.ActualHeight), "3. line count based on textblock.ActualHeight");
//Assert.AreEqual (576, tb.ActualHeight, "3. tb.ActualHeight");
tb.Width = 70;
b.Measure (new Size (Double.PositiveInfinity, Double.PositiveInfinity));
Assert.IsTrue (tb.ActualWidth < 10.9 && tb.ActualWidth > 10.8, "4. textblock.ActualWidth is " + tb.ActualWidth.ToString ());
Assert.AreEqual (29, GetLineCount (tb.ActualHeight), "4. line count based on textblock.ActualHeight");
//Assert.AreEqual (576, tb.ActualHeight, "4. tb.ActualHeight");
b.InvalidateMeasure ();
tb.InvalidateMeasure ();
b.Measure (new Size (Double.PositiveInfinity, Double.PositiveInfinity));
Assert.IsTrue (tb.ActualWidth < 10.9 && tb.ActualWidth > 10.8, "5. textblock.ActualWidth is " + tb.ActualWidth.ToString ());
Assert.AreEqual (29, GetLineCount (tb.ActualHeight), "5. line count based on textblock.ActualHeight");
//Assert.AreEqual (576, tb.ActualHeight, "5. tb.ActualHeight");
}
示例3: getTextWidthHeight
// return the dimension of the text after aplying styles from given textblock
private Point getTextWidthHeight(string text, TextBlock itemTextTB)
{
TextBlock tb = new TextBlock();
tb.Text = text;
tb.Style = itemTextTB.Style;
tb.FontFamily = itemTextTB.FontFamily;
tb.FontSize = itemTextTB.FontSize;
tb.FontSource = itemTextTB.FontSource;
tb.FontStretch = itemTextTB.FontStretch;
tb.FontStyle = itemTextTB.FontStyle;
tb.FontWeight = itemTextTB.FontWeight;
tb.InvalidateMeasure();
Point xy = new Point(tb.ActualWidth, tb.ActualHeight);
return xy;
}