GetMetadata() public method

public GetMetadata ( [ forType ) : PropertyMetadata
forType [
return PropertyMetadata
コード例 #1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="defaultValue">The default value of the Dependency Property</param>
        internal DependencyPropertyDetails(DependencyProperty property, Type dependencyObjectType) : this()
        {
            Property        = property;
            _hasWeakStorage = property.HasWeakStorage;

            Array.Copy(_unsetStack, _stack, _stackLength);

            var defaultValue = Property.GetMetadata(dependencyObjectType).DefaultValue;

            // Ensures that the default value of non-nullable properties is not null
            if (defaultValue == null && !Property.IsTypeNullable)
            {
                defaultValue = Property.GetFallbackDefaultValue();
            }

            _stack[MaxIndex] = defaultValue;

            Metadata = property.GetMetadata(dependencyObjectType);
        }
コード例 #2
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="defaultValue">The default value of the Dependency Property</param>
        internal DependencyPropertyDetails(DependencyProperty property, Type dependencyObjectType) : this()
        {
            Property        = property;
            _hasWeakStorage = property.HasWeakStorage;

            for (int i = 0; i < MaxIndex; i++)
            {
                _stack[i] = DependencyProperty.UnsetValue;
            }

            var defaultValue = Property.GetMetadata(dependencyObjectType).DefaultValue;

            // Ensures that the default value of non-nullable properties is not null
            if (defaultValue == null && !Property.IsTypeNullable)
            {
                defaultValue = Property.GetFallbackDefaultValue();
            }

            _stack[MaxIndex] = defaultValue;

            Metadata = property.GetMetadata(dependencyObjectType);
        }
コード例 #3
0
ファイル: fontchooser.xaml.cs プロジェクト: mhusen/Eto
        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;
        }