本文整理匯總了C#中Windows.UI.Xaml.DependencyProperty.GetMetadata方法的典型用法代碼示例。如果您正苦於以下問題:C# DependencyProperty.GetMetadata方法的具體用法?C# DependencyProperty.GetMetadata怎麽用?C# DependencyProperty.GetMetadata使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Windows.UI.Xaml.DependencyProperty
的用法示例。
在下文中一共展示了DependencyProperty.GetMetadata方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: InitializeFeaturePage
void InitializeFeaturePage(Grid grid, DependencyProperty chooserProperty, TypographyFeaturePage page)
{
if (page == null)
{
grid.Children.Clear();
grid.RowDefinitions.Clear();
}
else
{
// Get the property value and metadata.
object value = GetValue(chooserProperty);
var metadata = (TypographicPropertyMetadata)chooserProperty.GetMetadata(typeof(FontChooser));
// Look up the sample text.
string sampleText = (metadata.SampleTextTag != null) ? LookupString(metadata.SampleTextTag) :
_defaultSampleText;
if (page == _currentFeaturePage)
{
// Update the state of the controls.
for (int i = 0; i < page.Items.Length; ++i)
{
// Check the radio button if it matches the current property value.
if (page.Items[i].Value.Equals(value))
{
var radioButton = (RadioButton)grid.Children[i * 2];
radioButton.IsChecked = true;
}
// Apply properties to the sample text block.
var sample = (TextBlock)grid.Children[i * 2 + 1];
sample.Text = sampleText;
ApplyPropertiesToObjectExcept(sample, chooserProperty);
sample.SetValue(metadata.TargetProperty, page.Items[i].Value);
}
}
else
{
grid.Children.Clear();
grid.RowDefinitions.Clear();
// Add row definitions.
for (int i = 0; i < page.Items.Length; ++i)
{
var row = new RowDefinition();
row.Height = GridLength.Auto;
grid.RowDefinitions.Add(row);
}
// Add the controls.
for (int i = 0; i < page.Items.Length; ++i)
{
string tag = page.Items[i].Tag;
var radioContent = new TextBlock(new Run(LookupString(tag)));
radioContent.TextWrapping = TextWrapping.Wrap;
// Add the radio button.
var radioButton = new RadioButton();
radioButton.Name = tag;
radioButton.Content = radioContent;
radioButton.Margin = new Thickness(5.0, 0.0, 0.0, 0.0);
radioButton.VerticalAlignment = VerticalAlignment.Center;
Grid.SetRow(radioButton, i);
grid.Children.Add(radioButton);
// Check the radio button if it matches the current property value.
if (page.Items[i].Value.Equals(value))
{
radioButton.IsChecked = true;
}
// Hook up the event.
radioButton.Checked += featureRadioButton_Checked;
// Add the block with sample text.
var sample = new TextBlock(new Run(sampleText));
sample.Margin = new Thickness(5.0, 5.0, 5.0, 0.0);
sample.TextWrapping = TextWrapping.WrapWithOverflow;
ApplyPropertiesToObjectExcept(sample, chooserProperty);
sample.SetValue(metadata.TargetProperty, page.Items[i].Value);
Grid.SetRow(sample, i);
Grid.SetColumn(sample, 1);
grid.Children.Add(sample);
}
// Add borders between rows.
for (int i = 0; i < page.Items.Length; ++i)
{
var border = new Border();
border.BorderThickness = new Thickness(0.0, 0.0, 0.0, 1.0);
border.BorderBrush = SystemColors.ControlLightBrush;
Grid.SetRow(border, i);
Grid.SetColumnSpan(border, 2);
grid.Children.Add(border);
}
}
}
_currentFeature = chooserProperty;
_currentFeaturePage = page;
//.........這裏部分代碼省略.........