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


C# Xaml.DependencyObject類代碼示例

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


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

示例1: OnCacheUriChanged

        private static async void OnCacheUriChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            
            //Uri oldCacheUri = (Uri)e.OldValue;
            Uri newCacheUri = (Uri)d.GetValue(CacheUriProperty);
            var image = (Image)d;

            if (newCacheUri != null)
            {
                try
                {
                    //Get image from cache (download and set in cache if needed)
                    var cacheUri = await WebDataCache.GetLocalUriAsync(newCacheUri);

                    //Set cache uri as source for the image
                    image.Source = new BitmapImage(cacheUri);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex);

                    //Revert to using passed URI
                    image.Source = new BitmapImage(newCacheUri);
                }
            }
            else
                image.Source = null;

        }
開發者ID:vigneshmurugesan,項目名稱:Q42.WinRT,代碼行數:29,代碼來源:ImageExtensions.cs

示例2: SetDismissParentFlyout

 public static void SetDismissParentFlyout(DependencyObject obj, bool value)
 {
     if (obj != null)
     {
         obj.SetValue(DismissParentFlyoutProperty, value);
     }
 }
開發者ID:ali-hk,項目名稱:Toolkit,代碼行數:7,代碼來源:DismissParentFlyoutBehavior.cs

示例3: VisibilityChangedCallback

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

示例4: PositionChanged

 static void PositionChanged(DependencyObject dp, DependencyPropertyChangedEventArgs args)
 {
     var p = ((FrameworkElement)dp)?.Parent;
     if (p == null)
         return;
     ((UIElement)p)?.InvalidateArrange();
 }
開發者ID:NotExperiencedDev,項目名稱:AmP3,代碼行數:7,代碼來源:SimpleWorld.cs

示例5: OnCommandPropertyChanged

 private static void OnCommandPropertyChanged(DependencyObject d,
     DependencyPropertyChangedEventArgs e)
 {
     var control = d as ListViewBase;
     if (control != null)
         control.ItemClick += OnItemClick;
 }
開發者ID:smndtrl,項目名稱:Signal-UWP,代碼行數:7,代碼來源:ItemClickCommand.cs

示例6: Attach

        public void Attach(DependencyObject associatedObject)
        {
            AssociatedObject = associatedObject;

            // process start
            if (Windows.ApplicationModel.DesignMode.DesignModeEnabled)
            {
                element.Visibility = Visibility.Visible;
            }
            else
            {
                _dispatcher = Common.DispatcherWrapper.Current();

                // throttled calculate event
                var observable = Observable.FromEventPattern(this, nameof(DoCalculate));
                var throttled = observable.Throttle(TimeSpan.FromMilliseconds(1000));
                throttled.Subscribe(x => Calculate());

                // handle click
                element.Click += new Common.WeakReference<NavButtonBehavior, object, RoutedEventArgs>(this)
                {
                    EventAction = (i, s, e) => Element_Click(s, e),
                    DetachAction = (i, w) => element.Click -= w.Handler,
                }.Handler;
                Calculate();
            }
        }
開發者ID:bc3tech,項目名稱:Template10,代碼行數:27,代碼來源:NavButtonBehavior.cs

示例7: PrepareContainerForItemOverride

        protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
        {
            base.PrepareContainerForItemOverride(element, item);

            var listViewItem = element as ListViewItem;

            if (listViewItem != null)

            {
                var index = IndexFromContainer(element);

                var isOdd = (index + 1)%2 == 1;

                // support for adjusting to groups (each group should be threated individually)
                var collectionViewSource = Tag as CollectionViewSource;
                var groups = collectionViewSource?.Source as IEnumerable<AlphaKeyGroup>;
                if (groups != null)
                {
                    var o = Items?[index];
                    if (o != null)
                    {
                        var currentGroup = groups.FirstOrDefault(p => p.Contains(o));
                        index = currentGroup.IndexOf(o);
                        isOdd = (index + 1)%2 == 1;
                    }
                }

                listViewItem.Background = isOdd
                    ? OddRowBackground ?? new SolidColorBrush((Color) App.Current.Resources["SystemChromeLowColor"])
                    : EvenRowBackground;
            }
        }
開發者ID:haroldma,項目名稱:Audiotica,代碼行數:32,代碼來源:AlternatingRowListView.cs

示例8: Attach

        public void Attach( DependencyObject associatedObject )
        {
            AssociatedObject = associatedObject;

            var associatedControl = (Control) associatedObject;
            associatedControl.Loaded += ( _, __ ) => associatedControl.Focus( FocusState.Pointer );
        }
開發者ID:ValentinMinder,項目名稱:pocketcampus,代碼行數:7,代碼來源:FocusBehavior.cs

示例9: OnPathChanged

        private static void OnPathChanged( DependencyObject obj, DependencyPropertyChangedEventArgs args )
        {
            var icon = (Icon) obj;
            var data = (string) args.NewValue;

            if ( data == null )
            {
                return;
            }

            // Copy it since sharing it isn't permitted
            var path = (Path) XamlReader.Load( "<Path xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\" Data=\"" + data + "\" />" );

            path.Stretch = Stretch.Uniform;
            path.HorizontalAlignment = HorizontalAlignment.Center;
            path.VerticalAlignment = VerticalAlignment.Center;
            path.SetBinding( Path.FillProperty, new Binding { Source = icon, Path = new PropertyPath( "Foreground" ) } );
            path.SetBinding( Path.MarginProperty, new Binding { Source = icon, Path = new PropertyPath( "Padding" ) } );

            var container = new Border
            {
                Child = path
            };
            container.SetBinding( Border.WidthProperty, new Binding { Source = icon, Path = new PropertyPath( "IconWidth" ) } );
            container.SetBinding( Border.HeightProperty, new Binding { Source = icon, Path = new PropertyPath( "IconHeight" ) } );
            container.SetBinding( Border.BackgroundProperty, new Binding { Source = icon, Path = new PropertyPath( "Background" ) } );

            icon.HorizontalAlignment = HorizontalAlignment.Center;
            icon.VerticalAlignment = VerticalAlignment.Center;
            icon.Content = new Viewbox
            {
                Child = container
            };
        }
開發者ID:ValentinMinder,項目名稱:pocketcampus,代碼行數:34,代碼來源:Icon.cs

示例10: OnMessageChanged

 private static void OnMessageChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     var notifybar = d as NotificationBar;
     var message = e.NewValue as string;
     if (message == string.Empty) return;
     notifybar?.ShowMessage(message);
 }
開發者ID:startewho,項目名稱:CnBetaUWA,代碼行數:7,代碼來源:NotificationBar.cs

示例11: OnCommandPropertyChanged

 private static void OnCommandPropertyChanged(DependencyObject d,
     DependencyPropertyChangedEventArgs e)
 {
     var control = d as FrameworkElement;
     if (control != null)
         control.Tapped += OnTapped;
 }
開發者ID:DemosAndTrials,項目名稱:DemoCommandBinding,代碼行數:7,代碼來源:TappedCommand.cs

示例12: ApplyStyles

        public override void ApplyStyles(DocumentStyle style, DependencyObject ctrl, HtmlFragment fragment)
        {
            var caption = ctrl as Paragraph;
            caption.TextAlignment = Parse(style.Img.HorizontalAlignment);

            ApplyParagraphStyles(caption, style.FigCaption);
        }
開發者ID:ridomin,項目名稱:waslibs,代碼行數:7,代碼來源:FigCaptionWriter.cs

示例13: OnMaskChanged

 private static void OnMaskChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
 {
     var target = (TextBoxMaskBehavior)sender;
     var oldMask = (TextMask)e.OldValue;
     var newMask = (TextMask)e.NewValue;
     target.OnMaskChanged(oldMask, newMask);
 }
開發者ID:fubar-coder,項目名稱:bifrost.xaml,代碼行數:7,代碼來源:TextBoxMaskBehavior.cs

示例14: PrepareContainerForItemOverride

        protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
        {
            ItemsControlHelper.PrepareContainerForItemOverride(element, ItemContainerStyle);
            PreparePrepareHeaderedItemsControlContainerForItemOverride(element, item, this, ItemContainerStyle);

            base.PrepareContainerForItemOverride(element, item);
        }
開發者ID:nor0x,項目名稱:UWP_Expander,代碼行數:7,代碼來源:HeaderedItemsControl.cs

示例15: OnEndAngleChanged

 private static void OnEndAngleChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
 {
     var target = (PieSlice)sender;
     var oldEndAngle = (double)e.OldValue;
     var newEndAngle = (double)e.NewValue;
     target.OnEndAngleChanged(oldEndAngle, newEndAngle);
 }
開發者ID:chao-zhou,項目名稱:PomodoroTimer,代碼行數:7,代碼來源:PieSlice.cs


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