本文整理匯總了C#中System.Windows.Controls.TextBlock.GetType方法的典型用法代碼示例。如果您正苦於以下問題:C# TextBlock.GetType方法的具體用法?C# TextBlock.GetType怎麽用?C# TextBlock.GetType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Windows.Controls.TextBlock
的用法示例。
在下文中一共展示了TextBlock.GetType方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: BindTextBlock
internal void BindTextBlock(TextBlock textblock)
{
FieldInfo[] fields = this.GetType().GetFields();
foreach (FieldInfo field in fields)
{
DependencyProperty dp = (DependencyProperty)field.GetValue(this);
DependencyProperty dpTextblock = (DependencyProperty)(textblock.GetType().GetField(string.Concat(dp.Name, "Property")).GetValue(textblock));
Binding bindingTransform = new Binding(dp.Name);
bindingTransform.Source = this;
bindingTransform.Mode = BindingMode.OneWay;
BindingOperations.SetBinding(textblock, dpTextblock, bindingTransform);
}
}
示例2: clearOrderSelections
private void clearOrderSelections()
{
foreach (UIElement e in Order.Children) {
Label l = new Label() ;
TextBlock test = new TextBlock();
if (e.GetType() == test.GetType())
{
l.Content = ((TextBlock)e).Text;
}
else
{
l = (Label)e;
}
if (l.Tag != null && l.Tag.Equals("Item"))
{
if (!editing)
{
l.Background = defaultBackground;
}
}
else if (l.Tag != null && l.Tag.Equals("Option"))
{
l.Background = new SolidColorBrush(Colors.LightGreen);
l.Foreground = new SolidColorBrush(Colors.Black);
}
}
}