當前位置: 首頁>>代碼示例>>C#>>正文


C# Xaml.DependencyProperty類代碼示例

本文整理匯總了C#中Windows.UI.Xaml.DependencyProperty的典型用法代碼示例。如果您正苦於以下問題:C# DependencyProperty類的具體用法?C# DependencyProperty怎麽用?C# DependencyProperty使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DependencyProperty類屬於Windows.UI.Xaml命名空間,在下文中一共展示了DependencyProperty類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: StarRateControl

 public StarRateControl()
 {
     this.InitializeComponent();
     
     valueProperty = DependencyProperty.Register("Value", typeof(int), typeof(StarRateControl), new PropertyMetadata(3));
     
 }
開發者ID:ilpinnovations,項目名稱:MyILPWindowsPhone8.1,代碼行數:7,代碼來源:StarRateControl.xaml.cs

示例2: SetValueDp

        void SetValueDp(DependencyProperty property, object value, [System.Runtime.CompilerServices.CallerMemberName] String p = null)
        {
            SetValue(property, value);

            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(p));
        }
開發者ID:stenobot,項目名稱:MahjongAid,代碼行數:7,代碼來源:HelpOverlay.xaml.cs

示例3: FrameworkElementAttachedProperties

 static FrameworkElementAttachedProperties()
 {
     ObserveProperty = DependencyProperty.RegisterAttached("Observe", typeof(bool), typeof(FrameworkElementAttachedProperties), new PropertyMetadata(null, new PropertyChangedCallback(OnObserveChanged)));
     ObservedWidthProperty = DependencyProperty.RegisterAttached("ObservedWidth", typeof(double), typeof(FrameworkElementAttachedProperties), new PropertyMetadata(null, null));
     ObservedHeightProperty = DependencyProperty.RegisterAttached("ObservedHeight", typeof(double), typeof(FrameworkElementAttachedProperties), new PropertyMetadata(null, null));
     LoadedCommandProperty = DependencyProperty.RegisterAttached("LoadedCommand", typeof(ICommand), typeof(FrameworkElementAttachedProperties), new PropertyMetadata(null, OnLoadedCommandChanged));
 }
開發者ID:modulexcite,項目名稱:Lumia-imaging-sdk,代碼行數:7,代碼來源:FrameworkElementAttachedProperties.cs

示例4: OnHeaderPresenterContentChanged

 private void OnHeaderPresenterContentChanged(DependencyObject sender, DependencyProperty dp)
 {
     if (headerPresenter.Content != Header)
     {
         headerPresenter.Content = Header;
     }
 }
開發者ID:GJian,項目名稱:UWP-master,代碼行數:7,代碼來源:GroupListViewItem.cs

示例5: SuspendHandler

        /// <summary>
        /// Inherited code: Requires comment.
        /// </summary>
        /// <param name="obj">Inherited code: Requires comment 1.</param>
        /// <param name="dependencyProperty">Inherited code: Requires comment 2.</param>
        /// <param name="suspend">Inherited code: Requires comment 3.</param>
        private static void SuspendHandler(this DependencyObject obj, DependencyProperty dependencyProperty, bool suspend)
        {
            if (_suspendedHandlers.ContainsKey(obj))
            {
                Dictionary<DependencyProperty, bool> suspensions = _suspendedHandlers[obj];

                if (suspend)
                {
                    Debug.Assert(!suspensions.ContainsKey(dependencyProperty), "Suspensions should not contain the property!");

                    // true = dummy value
                    suspensions[dependencyProperty] = true;
                }
                else
                {
                    Debug.Assert(suspensions.ContainsKey(dependencyProperty), "Suspensions should contain the property!");
                    suspensions.Remove(dependencyProperty);
                    if (suspensions.Count == 0)
                    {
                        _suspendedHandlers.Remove(obj);
                    }
                }
            }
            else
            {
                Debug.Assert(suspend, "suspend should be true!");
                _suspendedHandlers[obj] = new Dictionary<DependencyProperty, bool>();
                _suspendedHandlers[obj][dependencyProperty] = true;
            }
        }
開發者ID:siatwangmin,項目名稱:WinRTXamlToolkit,代碼行數:36,代碼來源:CalendarExtensions.cs

示例6: SettingsEditor

        static SettingsEditor()
        {
            YScaleWidthProperty = DependencyProperty.Register("YScaleWidth", typeof(int), typeof(SettingsEditor), new PropertyMetadata(60));
            XScaleHeightProperty = DependencyProperty.Register("XScaleHeight", typeof(int), typeof(SettingsEditor), new PropertyMetadata(15));
            BorderThickness1Property = DependencyProperty.Register("BorderThickness1", typeof(int), typeof(SettingsEditor), new PropertyMetadata(1));
            BorderProperty = DependencyProperty.Register("Border", typeof(string), typeof(SettingsEditor), new PropertyMetadata("Black"));
            YScaleDockProperty = DependencyProperty.Register("YScaleDock", typeof(YScaleDock), typeof(SettingsEditor), new PropertyMetadata(YScaleDock.Right));
            ControlBackgroundProperty = DependencyProperty.Register("ControlBackground", typeof(string), typeof(SettingsEditor), new PropertyMetadata("White"));
            XScaleDockProperty = DependencyProperty.Register("XScaleDock", typeof(XScaleDock), typeof(SettingsEditor), new PropertyMetadata(XScaleDock.Bottom));
            CoordinateTypeProperty = DependencyProperty.Register("CoordinateType", typeof(CoordinateType), typeof(SettingsEditor), new PropertyMetadata(CoordinateType.Linear));
            CursorLinesProperty = DependencyProperty.Register("CursorLines", typeof(string), typeof(SettingsEditor), new PropertyMetadata("Gray"));
            CursorLinesThicknessProperty = DependencyProperty.Register("CursorLinesThickness", typeof(int), typeof(SettingsEditor), new PropertyMetadata(1));
            CursorLinesDashesProperty = DependencyProperty.Register("CursorLinesDashes", typeof(string), typeof(SettingsEditor), new PropertyMetadata(null));

            ScaleLineColorProperty = DependencyProperty.Register("ScaleLineColor", typeof(string), typeof(SettingsEditor), new PropertyMetadata("Gray"));
            ScaleLineThicknessProperty = DependencyProperty.Register("ScaleLineThickness", typeof(int), typeof(SettingsEditor), new PropertyMetadata(1));
            ScaleLineDashesProperty = DependencyProperty.Register("ScaleLineDashes", typeof(string), typeof(SettingsEditor), new PropertyMetadata(null));

            FontFamilyProperty = DependencyProperty.Register("FontFamily", typeof(string), typeof(SettingsEditor), new PropertyMetadata("Arial"));
            FontSizeProperty = DependencyProperty.Register("FontSize", typeof(int), typeof(SettingsEditor), new PropertyMetadata(10));

            widthArrayProperty = DependencyProperty.Register("widthArray", typeof(int[]), typeof(SettingsEditor), new PropertyMetadata(null));
            brushesProperty = DependencyProperty.Register("brushes", typeof(string[]), typeof(SettingsEditor), new PropertyMetadata(null));
            yScaleDocksProperty = DependencyProperty.Register("yScaleDocks", typeof(YScaleDock[]), typeof(SettingsEditor), new PropertyMetadata(null));
            xScaleDocksProperty = DependencyProperty.Register("xScaleDocks", typeof(XScaleDock[]), typeof(SettingsEditor), new PropertyMetadata(null));
            bgBrushesProperty = DependencyProperty.Register("bgBrushes", typeof(string[]), typeof(SettingsEditor), new PropertyMetadata(null));
            dockWidthArrayProperty = DependencyProperty.Register("dockWidthArray", typeof(int[]), typeof(SettingsEditor), new PropertyMetadata(null));
            coordinateTypesProperty = DependencyProperty.Register("coordinateTypes", typeof(CoordinateType[]), typeof(SettingsEditor), new PropertyMetadata(null));
            dashArrayProperty = DependencyProperty.Register("dashArray", typeof(string[]), typeof(SettingsEditor), new PropertyMetadata(null));
            fontNamesProperty = DependencyProperty.Register("fontNames", typeof(string[]), typeof(SettingsEditor), new PropertyMetadata(null));
            fontSizesProperty = DependencyProperty.Register("fontSizes", typeof(int[]), typeof(SettingsEditor), new PropertyMetadata(null));
        }
開發者ID:Waynext,項目名稱:ChartControls,代碼行數:32,代碼來源:SettingsEditor.xaml.cs

示例7: BeginAnimation

        /// <summary>
        /// Starts animating a dependency property of a framework element to a 
        /// target value.
        /// </summary>
        /// <param name="target">The element to animate.</param>
        /// <param name="animatingDependencyProperty">The dependency property to
        /// animate.</param>
        /// <param name="propertyPath">The path of the dependency property to 
        /// animate.</param>
        /// <param name="targetValue">The value to animate the dependency
        /// property to.</param>
        /// <param name="timeSpan">The duration of the animation.</param>
        /// <param name="easingFunction">The easing function to uses to
        /// transition the data points.</param>
        public static void BeginAnimation(
            this FrameworkElement target,
            DependencyProperty animatingDependencyProperty,
            string propertyPath,
            object targetValue,
            TimeSpan timeSpan,
            EasingFunctionBase easingFunction)
        {
            Storyboard storyBoard = target.Resources[GetStoryboardKey(propertyPath)] as Storyboard;

            if (storyBoard != null)
            {
                // Save current value
                object currentValue = target.GetValue(animatingDependencyProperty);
                storyBoard.Stop();
                // RestoreAsync that value so it doesn't snap back to its starting value
                target.SetValue(animatingDependencyProperty, currentValue);
                target.Resources.Remove(GetStoryboardKey(propertyPath));
            }

            storyBoard = CreateStoryboard(target, animatingDependencyProperty, propertyPath, ref targetValue, timeSpan, easingFunction);

            storyBoard.Completed += 
                (source, args) =>
                    {
                        storyBoard.Stop();
                        target.SetValue(animatingDependencyProperty, targetValue);
                        target.Resources.Remove(GetStoryboardKey(propertyPath));
                    };

            target.Resources.Add(GetStoryboardKey(propertyPath), storyBoard);
            storyBoard.Begin();
        }
開發者ID:siatwangmin,項目名稱:WinRTXamlToolkit,代碼行數:47,代碼來源:DependencyPropertyAnimationHelper.cs

示例8: OnItemsSourceChanged

        private void OnItemsSourceChanged(DependencyObject sender, DependencyProperty dp)
        {
            if (this.ItemsSource != null && ItemsSource is IGroupCollection)
            {
                groupCollection = (ItemsSource as IGroupCollection);
            }

            if (groupHeadersGrid != null)
            {
                groupHeadersGrid.Children.Clear();
            }

            groupDic.Clear();

            if (currentTopGroupHeader != null)
            {
                currentTopGroupHeader.DataContext = null;
                currentTopGroupHeader.Visibility = Visibility.Collapsed;
                if (groupHeadersGrid != null)
                {
                    groupHeadersGrid.Children.Add(currentTopGroupHeader);
                }
            }
            else
            {
                if (groupHeadersGrid != null)
                {
                    currentTopGroupHeader = CreateGroupHeader(null);
                    currentTopGroupHeader.Visibility = Visibility.Collapsed;
                    groupHeadersGrid.Children.Add(currentTopGroupHeader);
                }
            }
        }
開發者ID:GJian,項目名稱:UWP-master,代碼行數:33,代碼來源:GroupListView.cs

示例9: VisibilityChangedCallback

 private void VisibilityChangedCallback(DependencyObject sender, DependencyProperty dp)
 {
     if (Visibility == Visibility.Visible)
     {
         EntryBox.Text = FilterSting;
     }
 }
開發者ID:Opiumtm,項目名稱:DvachBrowser3,代碼行數:7,代碼來源:SearchBox.xaml.cs

示例10: TextBlockFontSize

 static TextBlockFontSize()
 {
     FontSizeProperty = DependencyProperty.Register("FontSize",
         typeof(int),
         typeof(TextBlockFontSize),
         new PropertyMetadata(TextBlock.FontSizeProperty, null));
 }
開發者ID:Romaxaqaz,項目名稱:Onliner,代碼行數:7,代碼來源:TextBlockFontSize.xaml.cs

示例11: RefreshBinding

 private static void RefreshBinding(DependencyObject target, DependencyProperty property)
 {
     BindingExpression binding = target.ReadLocalValue(property) as BindingExpression;
     if (binding != null && binding.ParentBinding != null)
     {
         BindingOperations.SetBinding(target, property, binding.ParentBinding);
     }
 }
開發者ID:JackieyLi,項目名稱:XamlBehaviors,代碼行數:8,代碼來源:DataBindingHelper.cs

示例12: SetBinding

 /// <summary>
 /// Sets a binding from code
 /// </summary>
 /// <param name="element"></param>
 /// <param name="property"></param>
 /// <param name="source"></param>
 /// <param name="path"></param>
 /// <param name="converter"></param>
 public static void SetBinding(FrameworkElement element, DependencyProperty property, object source, string path, IValueConverter converter = null)
 {
     Binding binding = new Binding();
     binding.Source = source;
     binding.Path = new PropertyPath(path);
     binding.Converter = converter;
     element.SetBinding(property, binding);
 }
開發者ID:knowlatest,項目名稱:Windows8StartKit,代碼行數:16,代碼來源:BindingHelper.cs

示例13: SetValueDp

 private void SetValueDp(DependencyProperty property, object value, [CallerMemberName] string propertyName = null)
 {
     SetValue(property, value);
     if (PropertyChanged != null)
     {
         PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
     }
 }
開發者ID:mjcdev,項目名稱:MorseCoder,代碼行數:8,代碼來源:MorseInput.xaml.cs

示例14: OnMinWindowWidthPropertyChanged

 private void OnMinWindowWidthPropertyChanged(DependencyObject sender, DependencyProperty dp)
 {
     var window = CoreApplication.GetCurrentView()?.CoreWindow;
     if (window != null)
     {
         IsActive = window.Bounds.Width >= MinWindowWidth;
     }
 }
開發者ID:yanxiaodi,項目名稱:WindowsStateTriggers,代碼行數:8,代碼來源:AdaptiveTrigger.cs

示例15: HeaderChanged

 void HeaderChanged(DependencyObject sender, DependencyProperty prop)
 {
     string header = (string)sender.GetValue(prop);
     //Double check to make sure that we don't needlessly realize the header presenter
     if (!string.IsNullOrEmpty(Header) && _header == null)
     {
         _header = (ContentPresenter)GetTemplateChild("HeaderPresenter"); //This will realize the element
     }
 }
開發者ID:C-C-D-I,項目名稱:Windows-universal-samples,代碼行數:9,代碼來源:TitledImage.cs


注:本文中的Windows.UI.Xaml.DependencyProperty類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。