Inheritance: IDependencyObject
Esempio n. 1
0
 private void VisibilityChangedCallback(DependencyObject sender, DependencyProperty dp)
 {
     if (Visibility == Visibility.Visible)
     {
         EntryBox.Text = FilterSting;
     }
 }
Esempio n. 2
0
 private static void OnCommandPropertyChanged(DependencyObject d,
     DependencyPropertyChangedEventArgs e)
 {
     var control = d as ListViewBase;
     if (control != null)
         control.ItemClick += OnItemClick;
 }
Esempio n. 3
0
        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();
            }
        }
        protected override void PrepareContainerForItemOverride(Windows.UI.Xaml.DependencyObject element, object item)
        {
            base.PrepareContainerForItemOverride(element, item);
            DataItem dataItem = item as DataItem;
            int      index    = -1;

            if (dataItem != null)
            {
                index = dataItem.Group.Items.IndexOf(dataItem);
            }

            if (index >= 0 && index < _sequence.Count)
            {
                colVal = (int)_sequence[index].Width;
                rowVal = (int)_sequence[index].Height;
            }
            else
            {
                colVal = (int)LayoutSizes.OtherSmallItem.Width;
                rowVal = (int)LayoutSizes.OtherSmallItem.Height;
            }

            VariableSizedWrapGrid.SetRowSpan(element as UIElement, rowVal);
            VariableSizedWrapGrid.SetColumnSpan(element as UIElement, colVal);
        }
        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;
            }
        }
Esempio n. 6
0
 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);
 }
Esempio n. 7
0
 private static void OnHeaderTemplatePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     var source = d as HeaderedItemsControl;
     var oldHeaderTemplate = e.OldValue as DataTemplate;
     var newHeaderTemplate = e.NewValue as DataTemplate;
     if (source != null) source.OnHeaderTemplateChanged(oldHeaderTemplate, newHeaderTemplate);
 }
Esempio n. 8
0
 static void PositionChanged(DependencyObject dp, DependencyPropertyChangedEventArgs args)
 {
     var p = ((FrameworkElement)dp)?.Parent;
     if (p == null)
         return;
     ((UIElement)p)?.InvalidateArrange();
 }
        public void Attach(DependencyObject associatedObject)
        {
            offsets = new List<double>();
            isHidden = true;
            buttonAdded = false;

            if (!DesignMode.DesignModeEnabled)
            {
                _associatedObject = associatedObject;

                scrollviewer = _associatedObject as ScrollViewer;

                if (scrollviewer != null)
                {
                    scrollviewer.ViewChanging += Scrollviewer_ViewChanging;
                    scrollviewer.Loaded += Scrollviewer_Loaded;
                }

                if (ScrollToTopButton != null)
                {
                    ScrollToTopButton.Tapped += ScrollToTopButton_Tapped;
                    ScrollToTopButton.Name = "ScrollToTopButton";
                }
            }
        }
Esempio n. 10
0
 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);
 }
 private static void OnTextChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
 {
     var target = (TextBoxMaskBehavior)sender;
     var oldText = (string)e.OldValue;
     var newText = (string)e.NewValue;
     target.OnTextChanged(oldText, newText);
 }
 private static void OnCommandPropertyChanged(DependencyObject d,
     DependencyPropertyChangedEventArgs e)
 {
     var control = d as FrameworkElement;
     if (control != null)
         control.Tapped += OnTapped;
 }
        ScrollViewer FindScrollViewer(DependencyObject depObject)
        {
            if (depObject == null)
            {
                return null;
            }

            int countThisLevel = Windows.UI.Xaml.Media.VisualTreeHelper.GetChildrenCount(depObject);
            if (countThisLevel <= 0)
            {
                return null;
            }

            for (int childIndex = 0; childIndex < countThisLevel; childIndex++)
            {
                DependencyObject childDepObject = Windows.UI.Xaml.Media.VisualTreeHelper.GetChild(depObject, childIndex);
                if (childDepObject is ScrollViewer)
                {
                    return (ScrollViewer)childDepObject;
                }

                ScrollViewer svFromChild = FindScrollViewer(childDepObject);
                if (svFromChild != null)
                {
                    return svFromChild;
                }
            }

            return null;
        }
Esempio n. 14
0
        private static async void SizeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) {
            if ((int)e.NewValue <= 0)
                throw new ArgumentException("ThumbImageSource width/height 必须大于0");

            var thumb = (ThumbImageSource)d;
            //await thumb.Deal();
        }
Esempio n. 15
0
        public void Attach( DependencyObject associatedObject )
        {
            AssociatedObject = associatedObject;

            var associatedControl = (Control) associatedObject;
            associatedControl.Loaded += ( _, __ ) => associatedControl.Focus( FocusState.Pointer );
        }
Esempio n. 16
0
 public TextBlock GetTextBlock(Windows.UI.Xaml.DependencyObject depObj)
 {
     if (depObj is TextBlock)
     {
         try
         {
             var ret = depObj as TextBlock;
             if (ret.DataContext.ToString() == "me")
             {
                 return(ret);
             }
             else
             {
                 return(null);
             }
         }
         catch
         {
             return(null);
         }
     }
     for (int i = Windows.UI.Xaml.Media.VisualTreeHelper.GetChildrenCount(depObj) - 1; i >= 0; i--)
     {
         var child  = Windows.UI.Xaml.Media.VisualTreeHelper.GetChild(depObj, i);
         var result = GetTextBlock(child);
         if (result != null)
         {
             return(result);
         }
     }
     return(null);
 }
Esempio n. 17
0
        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
            };
        }
 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);
 }
Esempio n. 19
0
        private static void OnNetworkStatusPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var obj = (NetworkStatusTrigger)d;
            var val = (NetworkStatus)e.NewValue;

            obj.SetActive(val == _status);
        }
Esempio n. 20
0
 /// <summary>
 /// Sets a command into the attached property.
 /// </summary>
 /// <param name="dependencyObject">The dependency object to assign the command.</param>
 /// <param name="value">The command to attach.</param>
 public static void SetCommand(DependencyObject dependencyObject, ICommand value)
 {
     if (dependencyObject != null)
     {
         dependencyObject.SetValue(CommandProperty, value);
     }
 }
        protected override DataTemplate SelectTemplateCore(object item, DependencyObject container)
        {
            var listItem = item as DataObject;
            var uiElement = container as FrameworkElement;

            if (listItem == null)
                return TextTemplate;

            Grid.SetColumn(uiElement, listItem.GridColumn);
            Grid.SetRow(uiElement, listItem.GridRow);
            Grid.SetColumnSpan(uiElement, listItem.GridColumnSpan);
            Grid.SetRowSpan(uiElement, listItem.GridRowSpan);

            switch (listItem.Type)
            {
                case DataObjectType.Shape:
                    return ShapeTemplate;
                case DataObjectType.Image:
                    return ImageTemplate;
                case DataObjectType.Text:
                    return TextTemplate;
            }

            return base.SelectTemplateCore(item, container);
        }
 protected override Windows.UI.Xaml.Style SelectStyleCore(object item, Windows.UI.Xaml.DependencyObject container)
 {
     if (item is TileTemplate)
     {
         TileTemplate tile = item as TileTemplate;
         if (tile.IsAvailable)
         {
             return(DefaultStyle);
         }
         else
         {
             return(UnavailableStyle);
         }
     }
     else if (item is TileGlyph)
     {
         TileGlyph glyph = item as TileGlyph;
         if (glyph.IsAvailable)
         {
             return(DefaultStyle);
         }
         else
         {
             return(UnavailableStyle);
         }
     }
     else
     {
         return(DefaultStyle);
     }
 }
Esempio n. 23
0
        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);
        }
Esempio n. 24
0
 private static void SearchBoxChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     var textBox = d as TextBox;
     if (textBox == null)
         throw new InvalidCastException("This extension is for TextBox only");
     var searchBox = e.NewValue as SearchBox;
     if (searchBox == null)
         return;
     searchBox.QuerySubmitted += (s, args) =>
     {
         var text = args.QueryText;
         if (string.IsNullOrEmpty(text))
         {
             textBox.SelectionLength = 0;
             return;
         }
         var index = textBox.Text.IndexOf(text);
         if (index < 0)
         {
             textBox.SelectionLength = 0;
             return;
         }
         textBox.SelectionStart = index;
         textBox.SelectionLength = text.Length;
         if (textBox.FocusState == FocusState.Unfocused)
             textBox.Focus(FocusState.Programmatic);
     };
 }
Esempio n. 25
0
        protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
        {
            ItemsControlHelper.PrepareContainerForItemOverride(element, ItemContainerStyle);
            PreparePrepareHeaderedItemsControlContainerForItemOverride(element, item, this, ItemContainerStyle);

            base.PrepareContainerForItemOverride(element, item);
        }
 // 依存関係プロパティに値がセットされたときに呼び出されるメソッド
 private static void OnSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     var i = d as TwitterSuggestTextBox;
     i.textBoxTweet.Text = (string)e.NewValue;
    // i.model.Text = (string)e.NewValue;
     
 }
Esempio n. 27
0
 private static void VerifyType(DependencyObject item)
 {
     if (!(item is IAction))
     {
         throw new InvalidOperationException(ResourceHelper.GetString("NonActionAddedToActionCollectionExceptionMessage"));
     }
 }
 public static void SetDismissParentFlyout(DependencyObject obj, bool value)
 {
     if (obj != null)
     {
         obj.SetValue(DismissParentFlyoutProperty, value);
     }
 }
        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;

        }
		private static void OnSelectedIndexPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
		{
			var item = (int)(e.NewValue);
			var ctrl = (SidePanel)d;
			if (item < ctrl.Items.Count)
				ctrl.SelectedItem = ctrl.Items[item];
		}
        public static string GetVisualState(DependencyObject sender) {
            if (sender == null) {
                return null;
            }

            return (string)sender.GetValue(GoToStateProperty);
        }
        public static void SetVisualState(DependencyObject sender, string state) {
            if (sender == null) {
                return;
            }

            sender.SetValue(GoToStateProperty, state);
        }
        private void DataContextChangedHandler(Windows.UI.Xaml.DependencyObject sender, Windows.UI.Xaml.DataContextChangedEventArgs args)
        {
            var newViewModel = args.NewValue as NativeStorageRuntimeTestsViewModel;

            ViewModel = newViewModel;
            if (newViewModel != null)
            {
                ViewModel.UnitTestsControl = UnitTestsControl;
            }
        }
Esempio n. 34
0
        protected override void PrepareContainerForItemOverride(Windows.UI.Xaml.DependencyObject element, object item)
        {
            var photoItem = item as PhotoItemToGridView;

            if (photoItem != null)
            {
                element.SetValue(VariableSizedWrapGrid.ColumnSpanProperty, photoItem.HorizontalSize);
                element.SetValue(VariableSizedWrapGrid.RowSpanProperty, photoItem.VerticalSize);
            }
            base.PrepareContainerForItemOverride(element, item);
        }
 protected override DataTemplate SelectTemplateCore(object item, Windows.UI.Xaml.DependencyObject container)
 {
     if ((item as GroupHeaderContext).IsExpanded == true)
     {
         return(this.ExpandedTemplate);
     }
     else
     {
         return(this.CollapsedTemplate);
     }
 }
        protected override void PrepareContainerForItemOverride(Windows.UI.Xaml.DependencyObject element, object item)
        {
            base.PrepareContainerForItemOverride(element, item);
            // ...
            ListViewItem listItem = element as ListViewItem;
            Binding      binding  = new Binding();

            binding.Mode   = BindingMode.TwoWay;
            binding.Source = item;
            binding.Path   = new PropertyPath("IsEnabled");
            listItem.SetBinding(ListViewItem.IsEnabledProperty, binding);
        }
Esempio n. 37
0
        public void Attach(Windows.UI.Xaml.DependencyObject associatedObject)
        {
            var mapControl = associatedObject as MapControl;

            if (mapControl == null)
            {
                throw new ArgumentException("PushpinCollectionBehavior can be attached only to MapControl");
            }

            AssociatedObject = associatedObject;

            mapControl.Unloaded += MapControlUnloaded;
        }
Esempio n. 38
0
        public static T FindChild <T> (this sw.DependencyObject parent, string childName = null)
            where T : sw.DependencyObject
        {
            // Confirm parent and childName are valid.
            if (parent == null)
            {
                return(null);
            }

            T foundChild = null;

            int childrenCount = swm.VisualTreeHelper.GetChildrenCount(parent);

            for (int i = 0; i < childrenCount; i++)
            {
                var child = swm.VisualTreeHelper.GetChild(parent, i);
                // If the child is not of the request child type child
                var childType = child as T;
                if (childType == null)
                {
                    // recursively drill down the tree
                    foundChild = FindChild <T> (child, childName);

                    // If the child is found, break so we do not overwrite the found child.
                    if (foundChild != null)
                    {
                        break;
                    }
                }
                else if (!string.IsNullOrEmpty(childName))
                {
                    var frameworkElement = child as sw.FrameworkElement;
                    // If the child's name is set for search
                    if (frameworkElement != null && frameworkElement.Name == childName)
                    {
                        // if the child's name is of the request name
                        foundChild = (T)child;
                        break;
                    }
                }
                else
                {
                    // child element found.
                    foundChild = (T)child;
                    break;
                }
            }

            return(foundChild);
        }
Esempio n. 39
0
        public void Attach(Windows.UI.Xaml.DependencyObject associatedObject)
        {
            var flyout = associatedObject as FlyoutBase;

            if (flyout == null)
            {
                throw new ArgumentException("FlyoutBehavior can be attached only to FlyoutBase");
            }

            AssociatedObject = associatedObject;

            flyout.Opened += FlyoutOpened;
            flyout.Closed += FlyoutClosed;
        }
Esempio n. 40
0
        public static T GetParent <T> (this sw.DependencyObject control)
            where T : sw.DependencyObject
        {
            var tmp = swm.VisualTreeHelper.GetParent(control);

            while (tmp != null)
            {
                tmp = swm.VisualTreeHelper.GetParent(tmp);
                var ttmp = tmp as T;
                if (ttmp != null)
                {
                    return(ttmp);
                }
            }
            return(null);
        }
        protected override DataTemplate SelectTemplateCore(object item, Windows.UI.Xaml.DependencyObject container)
        {
            // grab the Type name. Type will be searched as Type:NAME as shown below

            /*
             *  <DataTemplate x:Key="Type:SampleDataItem">
             *      <Grid HorizontalAlignment="Left" SurfaceWidth="250" SurfaceHeight="250">
             *          <TextBlock Text="{Binding Title}" />
             *      </Grid>
             *  </DataTemplate>
             */
            string key = item != null?string.Format("Type:{0}", item.GetType().Name.Split('.').Last()) : DefaultTemplateKey;

            DataTemplate dt = GetCachedDataTemplate(key);

            try
            {
                if (dt != null)
                {
                    return(dt);
                }

                // look at all parents (visual parents)
                FrameworkElement fe = container as FrameworkElement;
                while (fe != null)
                {
                    dt = FindTemplate(fe, key);
                    if (dt != null)
                    {
                        return(dt);
                    }
                    // if you were to just look at logical parents,
                    // you'd find that there isn't a Parent for Items set
                    fe = VisualTreeHelper.GetParent(fe) as FrameworkElement;
                }

                dt = FindTemplate(null, key);
                return(dt);
            }
            finally
            {
                if (dt != null)
                {
                    AddCachedDataTemplate(key, dt);
                }
            }
        }
Esempio n. 42
0
 public static ItemsWrapGrid GetItemsWrapGrid(Windows.UI.Xaml.DependencyObject depObj)
 {
     if (depObj is ItemsWrapGrid)
     {
         return(depObj as ItemsWrapGrid);
     }
     for (int i = 0; i < Windows.UI.Xaml.Media.VisualTreeHelper.GetChildrenCount(depObj); i++)
     {
         var child  = Windows.UI.Xaml.Media.VisualTreeHelper.GetChild(depObj, i);
         var result = GetItemsWrapGrid(child);
         if (result != null)
         {
             return(result);
         }
     }
     return(null);
 }
Esempio n. 43
0
 public RichTextBlock GetRichTextBlock(Windows.UI.Xaml.DependencyObject depObj)
 {
     if (depObj is RichTextBlock)
     {
         return(depObj as RichTextBlock);
     }
     for (int i = 0; i < Windows.UI.Xaml.Media.VisualTreeHelper.GetChildrenCount(depObj); i++)
     {
         var child  = Windows.UI.Xaml.Media.VisualTreeHelper.GetChild(depObj, i);
         var result = GetRichTextBlock(child);
         if (result != null)
         {
             return(result);
         }
     }
     return(null);
 }
Esempio n. 44
0
        public static ScrollViewer GetScrollViewer(Windows.UI.Xaml.DependencyObject depObj)
        {
            if (depObj is ScrollViewer)
            {
                return(depObj as ScrollViewer);
            }

            for (int i = 0; i < Windows.UI.Xaml.Media.VisualTreeHelper.GetChildrenCount(depObj); i++)
            {
                var child  = Windows.UI.Xaml.Media.VisualTreeHelper.GetChild(depObj, i);
                var result = GetScrollViewer(child);
                if (result != null)
                {
                    return(result);
                }
            }
            return(null);
        }
Esempio n. 45
0
 protected override void PrepareContainerForItemOverride(Windows.UI.Xaml.DependencyObject element, object item)
 {
     try
     {
         dynamic _Item = item;
         element.SetValue(Windows.UI.Xaml.Controls.VariableSizedWrapGrid.ColumnSpanProperty, _Item.ColSpan);
         element.SetValue(Windows.UI.Xaml.Controls.VariableSizedWrapGrid.RowSpanProperty, _Item.RowSpan);
     }
     catch
     {
         element.SetValue(Windows.UI.Xaml.Controls.VariableSizedWrapGrid.ColumnSpanProperty, 1);
         element.SetValue(Windows.UI.Xaml.Controls.VariableSizedWrapGrid.RowSpanProperty, 1);
     }
     finally
     {
         base.PrepareContainerForItemOverride(element, item);
     }
 }
        protected override DataTemplate SelectTemplateCore(object item, Windows.UI.Xaml.DependencyObject container)
        {
            //returns a default square template defined in StandarStyles.xaml
            return(Application.Current.Resources["Standard250x250ItemTemplate"] as DataTemplate);

            //returns a default 16:9 wide template defined in StandarStyles.xaml
            //return Application.Current.Resources["Standard445x250ItemTemplate"] as DataTemplate;

            //Note that we can also build out custom logic to determine which template to supply based on a property of Item
            //var selectedItem = item as Item;
            //if (selectedItem.Group.Contains("Youtube"))
            //{
            //    return Application.Current.Resources["Standard445x250ItemTemplate"] as DataTemplate;
            //}
            //else
            //{
            //    return Application.Current.Resources["Standard250x250ItemTemplate"] as DataTemplate;
            //}
        }
Esempio n. 47
0
        protected override void PrepareContainerForItemOverride(Windows.UI.Xaml.DependencyObject element, object item)
        {
            base.PrepareContainerForItemOverride(element, item);

            var       dataItem  = item as Domain.Models.UI.CustomGridBase;
            UIElement uiElement = element as UIElement;

            Binding colBinding = new Binding();

            colBinding.Source = dataItem;
            colBinding.Path   = new PropertyPath(this.ItemColSpanPropertyPath);
            BindingOperations.SetBinding(uiElement, VariableSizedWrapGrid.ColumnSpanProperty, colBinding);

            Binding rowBinding = new Binding();

            rowBinding.Source = dataItem;
            rowBinding.Path   = new PropertyPath(this.ItemRowSpanPropertyPath);
            BindingOperations.SetBinding(uiElement, VariableSizedWrapGrid.RowSpanProperty, rowBinding);
        }
Esempio n. 48
0
 protected override void PrepareContainerForItemOverride(Windows.UI.Xaml.DependencyObject element, object item)
 {
     try
     {
         dynamic model = item;
         element.SetValue(Windows.UI.Xaml.Controls.VariableSizedWrapGrid.ColumnSpanProperty, model.ColSpan);
         element.SetValue(Windows.UI.Xaml.Controls.VariableSizedWrapGrid.RowSpanProperty, model.RowSpan);
     }
     catch
     {
         element.SetValue(Windows.UI.Xaml.Controls.VariableSizedWrapGrid.ColumnSpanProperty, 1);
         element.SetValue(Windows.UI.Xaml.Controls.VariableSizedWrapGrid.RowSpanProperty, 1);
     }
     finally
     {
         element.SetValue(VerticalContentAlignmentProperty, VerticalAlignment.Stretch);
         element.SetValue(HorizontalContentAlignmentProperty, HorizontalAlignment.Stretch);
         base.PrepareContainerForItemOverride(element, item);
     }
 }
        protected override DataTemplate SelectTemplateCore(object item, Windows.UI.Xaml.DependencyObject container)
        {
            if (item is null)
            {
                return(BlankTemplate);
            }

            var customObject = (item as PropertyObjectViewModel);
            var type         = customObject.PropertyValue;

            if (type is null)
            {
                return(BlankTemplate);
            }
            if (type is string)
            {
                return(TextPropertyTemplate);
            }
            if (type is bool)
            {
                return(BooleanPropertyTemplate);
            }
            if (type is int)
            {
                return(NumericPropertyTemplate);
            }
            if (type is double)
            {
                return(NumericPropertyTemplate);
            }
            if (type is float)
            {
                return(NumericPropertyTemplate);
            }
            if (type is Color)
            {
                return(ColorPropertyTemplate);
            }

            return(BlankTemplate);
        }
Esempio n. 50
0
        protected override DataTemplate SelectTemplateCore(object item, Windows.UI.Xaml.DependencyObject container)
        {
            //returns a default square template defined in StandarStyles.xaml
            //return Application.Current.Resources["Standard250x250ItemTemplate"] as DataTemplate;

            //returns a default 16:9 wide template defined in StandarStyles.xaml
            //return Application.Current.Resources["Standard445x250ItemTemplate"] as DataTemplate;

            //Note that we can also build out custom logic to determine which template to supply based on a property of Item
            var selectedItem = item as Item;

            //Use Wide Template when source originates from Youtube API
            if (selectedItem.UrlSource != null && (selectedItem.UrlSource.Url.Contains("gdata.youtube.com") || selectedItem.UrlSource.Url.Contains("googleapis.com/youtube")))
            {
                return(Application.Current.Resources["Standard445x250ItemTemplate"] as DataTemplate);
            }
            else
            {
                return(Application.Current.Resources["Standard250x250ItemTemplate"] as DataTemplate);
            }
        }
Esempio n. 51
0
        protected override void PrepareContainerForItemOverride(Windows.UI.Xaml.DependencyObject element, object item)
        {
            base.PrepareContainerForItemOverride(element, item);
            UIElement uiElement = element as UIElement;

            if (EtcUtility.Instance.IsExistProperty(element, this.ItemColSpanPropertyPath) == true)
            {
                Binding colBinding = new Binding();
                colBinding.Source = item;
                colBinding.Path   = new PropertyPath(this.ItemColSpanPropertyPath);
                BindingOperations.SetBinding(uiElement, VariableSizedWrapGrid.ColumnSpanProperty, colBinding);
            }

            if (EtcUtility.Instance.IsExistProperty(element, this.ItemRowSpanPropertyPath) == true)
            {
                Binding rowBinding = new Binding();
                rowBinding.Source = item;
                rowBinding.Path   = new PropertyPath(this.ItemRowSpanPropertyPath);
                BindingOperations.SetBinding(uiElement, VariableSizedWrapGrid.RowSpanProperty, rowBinding);
            }
        }
Esempio n. 52
0
 /// <summary>
 /// Converts the SummaryRow into Style
 /// </summary>
 protected override Windows.UI.Xaml.Style SelectStyleCore(object item, Windows.UI.Xaml.DependencyObject container)
 {
     if ((item as SummaryRecordEntry).SummaryRow.ShowSummaryInRow)
     {
         var res   = new DataGrid.Summaries();
         var style = res.Resources["groupSummaryCell"] as Style;
         if (style != null)
         {
             return(style);
         }
     }
     else
     {
         var res   = new DataGrid.Summaries();
         var style = res.Resources["normalgroupSummaryCell"] as Style;
         if (style != null)
         {
             return(style);
         }
     }
     return(base.SelectStyleCore(item, container));
 }
Esempio n. 53
0
 /// <summary>
 /// Converts the SummaryRow into Style
 /// </summary>
 protected override Windows.UI.Xaml.Style SelectStyleCore(object item, Windows.UI.Xaml.DependencyObject container)
 {
     if ((item as SummaryRecordEntry).SummaryRow.ShowSummaryInRow)
     {
         var res = new DataGrid.ConditionalFormatting();
         var col = res.Resources["tableSummaryCell"] as Style;
         if (col != null)
         {
             return(col);
         }
     }
     else
     {
         var res = new DataGrid.ConditionalFormatting();
         var col = res.Resources["normaltableSummaryCell"] as Style;
         if (col != null)
         {
             return(col);
         }
     }
     return(base.SelectStyleCore(item, container));
 }
Esempio n. 54
0
        public static bool HasFocus(this sw.DependencyObject control, sw.DependencyObject focusScope, bool checkChildren = true)
        {
            var current = swi.FocusManager.GetFocusedElement(
#if TODO_XAML
                focusScope
#endif
                ) as sw.DependencyObject;

            if (!checkChildren)
            {
                return(current == control);
            }

            while (current != null)
            {
                if (current == control)
                {
                    return(true);
                }
                current = swm.VisualTreeHelper.GetParent(current);
            }
            return(false);
        }
Esempio n. 55
0
        protected override void PrepareContainerForItemOverride(Windows.UI.Xaml.DependencyObject element, object item)
        {
            Binding leftBinding = new Binding()
            {
                Path = new PropertyPath("Left"), Mode = BindingMode.TwoWay
            };
            Binding topBinding = new Binding()
            {
                Path = new PropertyPath("Top"), Mode = BindingMode.TwoWay
            };
            Binding zIndexBinding = new Binding()
            {
                Path = new PropertyPath("ZIndex"), Mode = BindingMode.TwoWay
            };

            FrameworkElement contentControl = (FrameworkElement)element;

            contentControl.SetBinding(Canvas.LeftProperty, leftBinding);
            contentControl.SetBinding(Canvas.TopProperty, topBinding);
            contentControl.SetBinding(Canvas.ZIndexProperty, zIndexBinding);

            base.PrepareContainerForItemOverride(element, item);
        }
Esempio n. 56
0
        private void CatToLV_Tapped(object sender, TappedRoutedEventArgs e)
        {
            //tapping category will look like tapping listview

            TextBlock Cat = (TextBlock)sender;


            //get listview containing the tapped category
            Windows.UI.Xaml.DependencyObject CatList = Cat;
            do
            {
                CatList = VisualTreeHelper.GetParent(CatList);
            }while (!(CatList is ListView));

            if (CurrMode == ADDING_MODE)
            {
                //move new item input field to "tapped" listview
                MoveNewItemField((ListView)CatList);

                //select the listviewitem corresponding to CatList
                if (CatList != MainList)
                {
                    Windows.UI.Xaml.DependencyObject CatListItem = CatList;
                    do
                    {
                        CatListItem = VisualTreeHelper.GetParent(CatListItem);
                    }while (!(CatListItem is ListViewItem));

                    ((ListViewItem)CatListItem).IsSelected = true;
                }
            }
            else if (CurrMode == DELETING_MODE)
            {
                RemoveItem((DependencyObject)CatList);
            }
        }
Esempio n. 57
0
 protected override void PrepareContainerForItemOverride(Windows.UI.Xaml.DependencyObject element, object item)
 {
     if (item is AdvertArticle)
     {
         var _UiElement = element as UIElement;
         if (_UiElement != null)
         {
             _UiElement.Visibility = Visibility.Collapsed;
         }
     }
     if (item is SummaryArticle)
     {
         var _Element = element as UIElement;
         if (_Element != null)
         {
             _Element.Visibility = Visibility.Collapsed;
         }
     }
     if (item is CalendarArticle)
     {
         var _UiElement1 = element as UIElement;
         if (_UiElement1 != null)
         {
             _UiElement1.Visibility = Visibility.Collapsed;
         }
     }
     if (item is WeatherArticle)
     {
         var _Element1 = element as UIElement;
         if (_Element1 != null)
         {
             _Element1.Visibility = Visibility.Collapsed;
         }
     }
     base.PrepareContainerForItemOverride(element, item);
 }
Esempio n. 58
0
 private void FolderPickerTests_DataContextChanged(Windows.UI.Xaml.DependencyObject sender, Windows.UI.Xaml.DataContextChangedEventArgs args)
 {
     ViewModel = args.NewValue as FileSavePickerTestsViewModel;
 }
 protected override Windows.UI.Xaml.DataTemplate SelectTemplateCore(object item, Windows.UI.Xaml.DependencyObject container)
 {
     if ((item as CustomObject).Flag == null)
     {
         return(this.NoImageFoundTemplate);
     }
     else
     {
         return(this.ImageTemplate);
     }
 }
Esempio n. 60
-1
        private async static  void UriSourcePropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
                Debug.WriteLine("我被触发了");
                StorageCachedImage image = d as StorageCachedImage;
                string i = e.NewValue as string;
                int k = i.IndexOf("image");
                string imagePath = i.Substring(k + 7);
                string uri = App.Uri + "public/images/" + imagePath;
                Debug.WriteLine(uri);
              
             
                Uri imageUri = new Uri(uri);

                HttpClient client = new HttpClient();
                var response = await client.GetAsync(imageUri);
                var buffer = await response.Content.ReadAsBufferAsync();
                var memoryStream = new InMemoryRandomAccessStream();
                await memoryStream.WriteAsync(buffer);
                await memoryStream.FlushAsync();
             
                await image.SetSourceAsync(memoryStream);
              
            

        }