private void DoLookups (FrameworkElement elem) { debug_panel.Children.Add (new TextBlock () { Text = String.Format ("Lookups from {0} ({1})", elem.Name, elem) }); debug_panel.Children.Add (new TextBlock () { Text = String.Format ("{0}.my_canvas: {1}", elem, elem.FindName ("my_canvas")) }); debug_panel.Children.Add (new TextBlock () { Text = String.Format ("{0}.sub_element: {1}", elem, elem.FindName ("sub_element")) }); debug_panel.Children.Add (new TextBlock () { Text = String.Format ("{0}.component_element: {1}", elem, elem.FindName ("component_element")) }); debug_panel.Children.Add (new Canvas () { Height = 20 }); }
public static object FindNameRecursive(this FrameworkElement element, string name) { FrameworkElement rootVisual = element.GetRootVisual(); if (rootVisual == null) { return(null); } return(rootVisual.FindName(name)); #if FALSE while (element != null) { object value = element.FindName(name); if (value != null) { return(value); } element = element.GetParent(); } return(null); #endif }
/// <internalonly /> public override object GetValue(FrameworkElement element) { if (String.IsNullOrEmpty(_propertyName)) { throw new InvalidOperationException("The PropertyName on an ElementProperty must be specified."); } object source = null; if (String.IsNullOrEmpty(_elementName)) { source = element.DataContext; } else if (String.CompareOrdinal(_elementName, "$self") == 0) { source = element; } else { source = element.FindName(_elementName); } if (source == null) { throw new InvalidOperationException("The ElementProperty could not find the specified element to use as the source of its value."); } PropertyInfo sourceProperty = source.GetType().GetProperty(_propertyName); if (sourceProperty == null) { throw new InvalidOperationException("The specified property '" + _propertyName + "' was not found on an object of type '" + source.GetType().FullName + "'"); } return sourceProperty.GetValue(source, null); }
internal static void SetDataContext( this DependencyObject source, DependencyProperty property, FrameworkElement element ) { Contract.Requires( source != null ); Contract.Requires( property != null ); // if there's no context that can be used to for updating, there's no sense in continuing if ( element == null || element.DataContext == null ) return; // get the data binding expression var expression = source.ReadLocalValue( property ) as BindingExpression; // if there's no expression, then parameter isn't data bound if ( expression == null || expression.ParentBinding == null ) return; var currentBinding = expression.ParentBinding; // skip one-time or relative source bindings if ( currentBinding.Mode == BindingMode.OneTime || currentBinding.RelativeSource != null ) return; // clone current binding and set source to data context of associated object var binding = currentBinding.Clone(); if ( !string.IsNullOrEmpty( binding.ElementName ) ) binding.Source = element.FindName( binding.ElementName ) ?? element.DataContext; else binding.Source = element.DataContext; // update binding BindingOperations.SetBinding( source, property, binding ); }
/// <summary> /// Finds the frame identified with given name in the specified context. /// </summary> /// <param name="name">The frame name.</param> /// <param name="context">The framework element providing the context for finding a frame.</param> /// <returns>The frame or null if the frame could not be found.</returns> public static ModernFrame FindFrame(string name, FrameworkElement context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } // collect all ancestor frames var frames = context.AncestorsAndSelf().OfType<ModernFrame>().ToArray(); switch (name) { case null: case FrameSelf: // find first ancestor frame return frames.FirstOrDefault(); case FrameParent: // find parent frame return frames.Skip(1).FirstOrDefault(); case FrameTop: // find top-most frame return frames.LastOrDefault(); } // find ancestor frame having a name matching the target var frame = frames.FirstOrDefault(f => f.Name == name); if (frame != null) return frame; // find frame in context scope frame = context.FindName(name) as ModernFrame; if (frame != null) return frame; // find frame in scope of ancestor frame content var parent = frames.FirstOrDefault(); var content = parent?.Content as FrameworkElement; return content?.FindName(name) as ModernFrame; }
public static object GetBoundMember(FrameworkElement element, string name) { object result = element.FindName(name); if (result == null) { return OperationFailed.Value; } return result; }
// Token: 0x06000D01 RID: 3329 RVA: 0x000306C8 File Offset: 0x0002E8C8 private static void CopyStoryboardTargetProperties(FrameworkElement root, Timeline source, Timeline destination) { if (source != null || destination != null) { string targetName = Storyboard.GetTargetName(source); DependencyObject dependencyObject = Storyboard.GetTarget(source); PropertyPath targetProperty = Storyboard.GetTargetProperty(source); if (dependencyObject == null && !string.IsNullOrEmpty(targetName)) { dependencyObject = (root.FindName(targetName) as DependencyObject); } if (targetName != null) { Storyboard.SetTargetName(destination, targetName); } if (dependencyObject != null) { Storyboard.SetTarget(destination, dependencyObject); } if (targetProperty != null) { Storyboard.SetTargetProperty(destination, targetProperty); } } }
private static void CopyStoryboardTargetProperties(FrameworkElement root, Timeline source, Timeline destination) { if (source != null || destination != null) { // Target takes priority over TargetName string targetName = Storyboard.GetTargetName(source); DependencyObject target = Storyboard.GetTarget(source); PropertyPath path = Storyboard.GetTargetProperty(source); if (target == null && !string.IsNullOrEmpty(targetName)) { target = root.FindName(targetName) as DependencyObject; } if (targetName != null) { Storyboard.SetTargetName(destination, targetName); } if (target != null) { Storyboard.SetTarget(destination, target); } if (path != null) { Storyboard.SetTargetProperty(destination, path); } } }
private static Timeline GenerateToAnimation(FrameworkElement root, Timeline timeline, bool isEntering) { Timeline result = null; Color?targetColor = GetTargetColor(timeline, isEntering); if (targetColor.HasValue) { ColorAnimation ca = new ColorAnimation() { To = targetColor }; result = ca; } if (result == null) { double?targetDouble = GetTargetDouble(timeline, isEntering); if (targetDouble.HasValue) { DoubleAnimation da = new DoubleAnimation() { To = targetDouble }; result = da; } } if (result == null) { Point?targetPoint = GetTargetPoint(timeline, isEntering); if (targetPoint.HasValue) { PointAnimation pa = new PointAnimation() { To = targetPoint }; result = pa; } } if (result != null) { string targetName = Storyboard.GetTargetName(timeline); Storyboard.SetTargetName(result, targetName); if (!String.IsNullOrEmpty(targetName)) { DependencyObject target = root.FindName(targetName) as DependencyObject; if (target != null) { Storyboard.SetTarget(result, target); } } Storyboard.SetTargetProperty(result, Storyboard.GetTargetProperty(timeline)); } return(result); }
private static System.Windows.FrameworkElement smethod_0(System.Windows.FrameworkElement dependencyObject_0, string string_0) { if (dependencyObject_0 == null) { return(null); } System.Windows.FrameworkElement obj2 = (System.Windows.FrameworkElement)dependencyObject_0.FindName(string_0); if (obj2 != null) { return(obj2); } return(null); }
public ToolTipHelper(FrameworkElement panel) { this.panel = panel; InitStatusMap(); //TooltipControl tooltip = new TooltipControl(); Grid rootView = panel.FindName("root") as Grid; rootView.Children.Add(tooltip); tooltip.registerObserver(this); panel.PreviewMouseUp +=new MouseButtonEventHandler(panel_PreviewMouseUp); tooltip.MouseUp +=new MouseButtonEventHandler(tooltip_MouseUp); }
/// <summary> /// Finds the frame identified with given name in the specified context. /// </summary> /// <param name="name">The frame name.</param> /// <param name="context">The framework element providing the context for finding a frame.</param> /// <returns>The frame or null if the frame could not be found.</returns> public static ModernFrame FindFrame(string name, FrameworkElement context) { if (context == null) { throw new ArgumentNullException("context"); } // collect all ancestor frames var frames = context.AncestorsAndSelf().OfType<ModernFrame>().ToArray(); if (name == null || name == FrameSelf) { // find first ancestor frame return frames.FirstOrDefault(); } if (name == FrameParent) { // find parent frame return frames.Skip(1).FirstOrDefault(); } if (name == FrameTop) { // find top-most frame return frames.LastOrDefault(); } // find ancestor frame having a name matching the target var frame = frames.FirstOrDefault(f => f.Name == name); if (frame == null) { // find frame in context scope frame = context.FindName(name) as ModernFrame; if (frame == null) { // find frame in scope of ancestor frame content var parent = frames.FirstOrDefault(); if (parent != null && parent.Content != null) { var content = parent.Content as FrameworkElement; if (content != null) { frame = content.FindName(name) as ModernFrame; } } } } return frame; }
public static object GetBoundMember(FrameworkElement e, string n) { //Search through the WpfElement's objects object result = e.FindName(n); if (result == null) { return OperationFailed.Value; } return result; //If we wanted to add The dynamic Python-type support for adding/removing things to the CLR Classes, we can create a Dict and return the pertinent stuff //And also create a SpecialName SetMemberAfter method. }
public static FantasyFrame FindFrame(String name, FrameworkElement context) { if (context == null) { throw new ArgumentNullException("context"); } // collect all ancestor frames FantasyFrame[] frames = context.Ancestors().OfType<FantasyFrame>().ToArray(); if (String.IsNullOrEmpty(name) || name.Equals(FrameSelf)) { // find the first frame. return frames.FirstOrDefault(); } if (name.Equals(FrameParent)) { // find parent frame return frames.Skip(1).FirstOrDefault(); } if (name.Equals(FrameTop)) { // find top-most frame return frames.LastOrDefault(); } // find ancestor frame having a name matching the target FantasyFrame frame = frames.FirstOrDefault(f => f.Name == name); if (frame == null) { // find frame in context scope frame = context.FindName(name) as FantasyFrame; if (frame == null) { // find frame in scope of ancestor frame content FantasyFrame parent = frames.FirstOrDefault(); if (parent != null && parent.Content != null) { FrameworkElement content = parent.Content as FrameworkElement; if (content != null) { frame = content.FindName(name) as FantasyFrame; } } } } return frame; }
public static bool SetupTextBoxBinding(System.Windows.FrameworkElement xamlRoot, string controlName, string bindingName, BindingMode bindingMode, object bindingSource, IValueConverter converter = null) { TextBox box = (TextBox)xamlRoot.FindName(controlName); if (box == null) { return(false); } Binding binding1 = new Binding(bindingName) { Mode = bindingMode, Source = bindingSource, Converter = converter }; box.SetBinding(TextBox.TextProperty, binding1); return(true); }
public static object GetFirstDataContextInVisualTree(FrameworkElement root) { if (null != root.DataContext) { return root.DataContext; } Func<UIElementCollection,object> walkChildren = (c) => { foreach (FrameworkElement child in c) { var returnValue = GetFirstDataContextInVisualTree(child); if (null != returnValue) { return returnValue; } } return null; }; object result = null; if (root is Panel) { result = walkChildren(((Panel) root).Children); } else if( root is Grid ) { result = walkChildren(((Grid) root).Children); } else if( root is ContentControl ) { result = GetFirstDataContextInVisualTree((FrameworkElement)((ContentControl)root).Content); } else { var layoutRoot = root.FindName("LayoutRoot") as FrameworkElement; if( null != layoutRoot ) { result = GetFirstDataContextInVisualTree(layoutRoot); } } return result; }
public void DispatchSubEvent(FrameworkElement page) { var filterList = (ListBox)page.FindName("EventFilterList"); var optionalFiltersList = (ListBox)page.FindName("OptionalEventFilterList"); _dispatchDelegate = (model, optinalActions) => { var filter = filterList.SelectedValue as Func<Term, bool>; var optionalFilters = optionalFiltersList.SelectedItems; Func<Term, bool> where = t => { if (!filter(t)) return false; foreach (var func in optionalFilters.Cast<ICustomFilter>().Select(o => o.WhereClause).OfType<Func<Term, bool>>()) if (!func(t)) return false; return true; }; var action = default(Action<Term, TimeBox>); foreach (var act in optinalActions.Cast<ICustomAction>().Select(o => o.Action).OfType<Action<Term, TimeBox>>()) action += act; TryDispatch(model, where, action); }; }
/// <summary> /// Creates a new SelectableImage /// </summary> public SelectableImage() { System.IO.Stream s = this.GetType().Assembly.GetManifestResourceStream( "Next2Friends.Swoosher.SelectableImage.xaml" ); root = this.InitializeFromXaml( new System.IO.StreamReader( s ).ReadToEnd() ); progress = (ProgressBar)root.FindName( "progress" ); content = (Canvas)root.FindName( "content" ); outline = (Rectangle)root.FindName( "outline" ); border = (Rectangle)root.FindName( "border" ); selection = (Rectangle)root.FindName( "selection" ); image = (Image)root.FindName( "image" ); //webImage = (Image)root.FindName( "webImage" ); root.Loaded += OnLoaded; downloader = new Downloader(); downloader.DownloadProgressChanged += image_DownloadProgressChanged; downloader.DownloadFailed += image_Failed; downloader.Completed += image_Completed; }
private void DeleteItem(FrameworkElement deleteBtn) { var storyboard = AnimationUtils.GetStoryboard(); FrameworkElement item = deleteBtn.FindName("ListItem") as FrameworkElement; AnimationUtils.SetOpacityAnimation(storyboard, item, 0, 0.3); AnimationUtils.SetHeightAnimation(storyboard, item, 0, 0.3); storyboard.Completed += delegate(object sender, EventArgs e) { App.ViewModel.DeleteToDoItem(item.DataContext as ToDoItem); }; storyboard.Begin(); }
private object GetControl(FrameworkElement parent, string controlName) { if (parent != null) { return parent.FindName(controlName); } return null; }
/// <summary> /// Initializes the view. /// </summary> /// <param name="dataContext">The data context.</param> /// <param name="view">The view.</param> private static void initView(object dataContext, FrameworkElement view) { RoutedEventHandler handler = null; view.DataContext = dataContext; handler = (o, e) => { var rootPanel = (Panel)view.FindName(LayoutRoot); System.Diagnostics.Debug.Assert(rootPanel != null); rootPanel.DataContext = dataContext; }; view.Loaded += handler; }
public static void CenterTextBlock (string blkName, FrameworkElement element) { TextBlock blk = element.FindName (blkName) as TextBlock; CenterTextBlock (blk, element); }
/// <summary> /// Updates the name scope. /// </summary> /// <param name="nameScope">The name scope.</param> public void UpdateNameScope( FrameworkElement nameScope ) { if ( _isInitialized ) { _nameScope = nameScope; foreach ( BindingSlave slave in Children ) { var bindingExpression = slave.GetBindingExpression ( BindingSlave.ValueProperty ); if ( bindingExpression != null ) { var oldbinding = bindingExpression.ParentBinding; if ( _nameScope != null && !string.IsNullOrEmpty ( oldbinding.ElementName ) ) { var element = _nameScope.FindName ( oldbinding.ElementName ); if ( element != null ) { var binding = new Binding { BindsDirectlyToSource = oldbinding.BindsDirectlyToSource, Converter = oldbinding.Converter, ConverterCulture = oldbinding.ConverterCulture, ConverterParameter = oldbinding.ConverterParameter, FallbackValue = oldbinding.FallbackValue, Mode = oldbinding.Mode, NotifyOnValidationError = oldbinding.NotifyOnValidationError, Path = oldbinding.Path, StringFormat = oldbinding.StringFormat, TargetNullValue = oldbinding.TargetNullValue, UpdateSourceTrigger = oldbinding.UpdateSourceTrigger, ValidatesOnDataErrors = oldbinding.ValidatesOnDataErrors, ValidatesOnExceptions = oldbinding.ValidatesOnExceptions, ValidatesOnNotifyDataErrors = oldbinding.ValidatesOnNotifyDataErrors }; binding.Source = element; slave.ClearValue ( BindingSlave.ValueProperty ); slave.SetBinding ( BindingSlave.ValueProperty, binding ); } } } } } }
/// <summary> /// Configures various elements found on the given UIElement /// to become control points. /// </summary> /// <param name="root"> /// The UIElement that might contain the specially named objects to /// be hooked up. /// </param> /// <remarks> /// This looks up elements named "desklet-close" and "desklet-drag" /// elements from the given root element and hooks up mouse events /// so that they trigger a close action and a drag action on the /// desklet. /// </remarks> public static void SetupToolbox (FrameworkElement root) { UIElement close = root.FindName ("desklet-close") as UIElement; if (close != null){ SetupOnClick (close, delegate { // When we move to multiple desklets on an // appdomain we will need to change this to // use some sort of global reference count and // only shut Gtk when the count reaches zero. Application.Quit (); }); } UIElement drag = root.FindName ("desklet-drag") as UIElement; if (drag != null){ // // TODO: we need to pass the Gtk.Window, sort out // a way of getting this information from mopen or // from the surface // SetupOnClick (drag, delegate { Console.WriteLine ("On drag not enabled, as we do not know our Gtk.Window yet"); } ); } }
/// <summary> /// Find an element with the specified name, from the indicated root UI element and, optionally, /// check whether it is a descendant of the specified type. /// </summary> /// <param name="root">The FrameworkElement which may contain the named element</param> /// <param name="name">Name of the element to look for</param> /// <param name="type">If not null, specifies the type the element must be descendant from, in order /// for the lookup to succeed</param> /// <remarks> /// If all elements looked up with this method were found and matched the specified types, the /// <see cref="M:AllElementsFound"/> property will return true. /// </remarks> /// <returns> /// The element looked for or null, if not found or if its type doesn't match the one specified in the type /// parameter. /// </returns> public static object FindElement (FrameworkElement root, string name, Type type) { DependencyObject ret = root.FindName (name) as DependencyObject; if (ret == null) _allElementsFound = false; if (type != null && !type.IsInstanceOfType (ret)) _allElementsFound = false; return ret; }
/// <summary> /// Ensures that a framework element has a unique name. /// </summary> /// <param name="element">The element to set the name of. /// </param> private static void EnsureName(FrameworkElement element) { Debug.Assert(element != null, "The framework element cannot be null."); if (string.IsNullOrEmpty(element.Name)) { string newName; do { newName = string.Format(CultureInfo.InvariantCulture, "__UniqueId{0}__", UniqueId++); } while (element.FindName(newName) != null); element.SetValue(FrameworkElement.NameProperty, newName); } }
internal static FrameworkElement GetChildByName(this FrameworkElement element, string name) { return((FrameworkElement)element.FindName(name) ?? element.ChildrenOfType <FrameworkElement>().FirstOrDefault(c => c.Name == name)); }
/// /// <summary> /// This event fires when event is about to be displayed on the screen, /// we attach event handlers to stop/play mediaplayer link here</summary> /// void OnEventCreated( FrameworkElement element, TimelineDisplayEvent de ) { MediaElement me; TimelineLibrary.Hyperlink link; me = element.FindName("MediaPlayer") as MediaElement; link = element.FindName("StopPlayButton") as TimelineLibrary.Hyperlink; if (me != null && link != null) { link.Tag = me; link.Click += new RoutedEventHandler(OnButtonClick); me.MediaEnded += new RoutedEventHandler(OnMediaEnded); me.Tag = false; } }
public void DispatchAssignment(FrameworkElement page) { var filterList = (ListBox)page.FindName("AssignmentFilterList"); _dispatchDelegate = (model, optinalActions) => { var filter = filterList.SelectedValue as Func<Term, bool>; var action = default(Action<Term, TimeBox>); foreach (var act in optinalActions.Cast<ICustomAction>().Select(o => o.Action).OfType<Action<Term, TimeBox>>()) action += act; TryDispatch(model, filter, action); }; }
/// /// <summary> /// Once new visual element is created for timeline event we attach /// event handlers to it's elements</summary> /// private new void OnEventCreated( FrameworkElement element, TimelineDisplayEvent de ) { Grid b; Border bsize; Border bdescr; Border bduration; Hyperlink hlink; b = element.FindName("EventTemplateRoot") as Grid; bsize = element.FindName("ResizeButton") as Border; bdescr = element.FindName("EventDescriptionBorder") as Border; bduration = element.FindName("DurationChangeBorder") as Border; hlink = element.FindName("EditButton") as Hyperlink; if (hlink != null) { hlink.Click += OnEditClick; hlink.Tag = de; } if (bdescr != null) { bdescr.MouseLeftButtonDown += CaptureMouse; bdescr.MouseLeftButtonUp += ReleaseMouse; bdescr.MouseMove += OnDescriptionMouseMove; bdescr.Tag = element; } if (bduration != null) { bduration.MouseLeftButtonDown += CaptureMouse; bduration.MouseLeftButtonUp += ReleaseMouse; bduration.MouseMove += OnBDurationMouseMove; bduration.Tag = element; } if (bsize != null) { bsize.MouseLeftButtonDown += CaptureMouse; bsize.MouseLeftButtonUp += ReleaseMouse; bsize.MouseMove += OnResizeMouseMove; bsize.Tag = b; } }
/// <summary> /// Builds the visual tree for the control /// when a new template is applied. /// </summary> public override void OnApplyTemplate() { base.OnApplyTemplate(); menuContainer = GetTemplateChild(MenuContainer) as FrameworkElement; if (menuContainer != null) { if (RootVisual != null) { menuContainer.Width = RootVisual.ActualWidth; } showMenuAnimation = menuContainer.FindName("storyBoard") as Storyboard; if (showMenuAnimation != null) { showMenuAnimation.Completed += StoryBoard_Completed; } for (int i = 0; i < Items.Count; i++) { if (Items[i] is TextBlock && ShouldApplyDefaultItemStyle) { TextBlock t = Items[i] as TextBlock; int pos = Items.IndexOf(t); Items.Remove(t); Border border = new Border(); border.BorderThickness = new Thickness(0); border.Child = t; border.Margin = t.Margin; t.Margin = new Thickness(0); Items.Insert(pos, border); } } } ChangeVisualState(false); isTemplateApplied = true; while (afterTemplateApplied.Count > 0) { var action = afterTemplateApplied.Dequeue(); action.Invoke(); } }
private void PreserveFocusState(FrameworkElement parent) { Control focusedControl = FocusManager.GetFocusedElement() as Control; if (focusedControl == null) { } else { Control controlWithFocus = parent.FindName(focusedControl.Name) as Control; if (controlWithFocus == null) { } else { State["FocusedElementName"] = controlWithFocus.Name; } } }
/// /// <summary> /// Once visual element is deleted we mark that there are no currently /// playing videos</summary> /// private void OnEventDeleted( FrameworkElement element, TimelineLibrary.TimelineDisplayEvent de ) { MediaElement me; me = element.FindName("MediaPlayer") as MediaElement; if (me == m_playing && me != null) { m_playing.Stop(); m_playing = null; } }
public ContentFlipperContent(FrameworkElement container, Size size) { _container = container; _viewport = (ViewportControl)container.FindName("FlipperViewport"); _canvas = (Canvas)container.FindName("FlipperCanvas"); _zoomableContent = (FrameworkElement)container.FindName("FlipperZoomableContent"); _transform = (ScaleTransform)container.FindName("FlipperZoomableContentTransform"); _zoomableContent.ManipulationStarted += OnManipulationStarted; _zoomableContent.ManipulationDelta += OnManipulationDelta; _zoomableContent.ManipulationCompleted += OnManipulationCompleted; _zoomableContent.LayoutUpdated += OnZoomableContentLayoutUpdated; SetSize(size); }
Button GetChildCollapseButton(FrameworkElement control) { Button button = control.FindName("CollapsableButton") as Button; if (button == null) { Logger.Debug("Control {0} did not have a button named CollapsableButton, this is probably an error", LogSource.UI, control); return null; } return button; }
private static Storyboard GenerateDynamicTransitionAnimations(FrameworkElement root, VisualStateGroup group, VisualState newState, VisualTransition transition) { Storyboard dynamic = new Storyboard(); if (transition != null && transition.GeneratedDuration != null) { dynamic.Duration = transition.GeneratedDuration; } else { dynamic.Duration = new Duration(TimeSpan.Zero); } Dictionary <TimelineDataToken, Timeline> currentAnimations = FlattenTimelines(group.CurrentStoryboards); Dictionary <TimelineDataToken, Timeline> transitionAnimations = FlattenTimelines(transition != null ? transition.Storyboard : null); Dictionary <TimelineDataToken, Timeline> newStateAnimations = FlattenTimelines(newState.Storyboard); // Remove any animations that the transition already animates. // There is no need to create an interstitial animation if one already exists. foreach (KeyValuePair <TimelineDataToken, Timeline> pair in transitionAnimations) { currentAnimations.Remove(pair.Key); newStateAnimations.Remove(pair.Key); } // Generate the "to" animations foreach (KeyValuePair <TimelineDataToken, Timeline> pair in newStateAnimations) { // The new "To" Animation -- the root is passed as a reference point for name // lookup. Timeline toAnimation = GenerateToAnimation(root, pair.Value, true); // If the animation is of a type that we can't generate transition animations // for, GenerateToAnimation will return null, and we should just keep going. if (toAnimation != null) { toAnimation.Duration = dynamic.Duration; dynamic.Children.Add(toAnimation); } // Remove this from the list of current state animations we have to consider next currentAnimations.Remove(pair.Key); } // Generate the "from" animations foreach (KeyValuePair <TimelineDataToken, Timeline> pair in currentAnimations) { Timeline fromAnimation = GenerateFromAnimation(pair.Value); if (fromAnimation != null) { fromAnimation.Duration = dynamic.Duration; string targetName = Storyboard.GetTargetName(pair.Value); Storyboard.SetTargetName(fromAnimation, targetName); // If the targetName of the existing Animation is known, then look up the // target DependencyObject target = String.IsNullOrEmpty(targetName) ? null : root.FindName(targetName) as DependencyObject; if (target != null) { Storyboard.SetTarget(fromAnimation, target); } PropertyPath propertyName = Storyboard.GetTargetProperty(pair.Value); Storyboard.SetTargetProperty(fromAnimation, propertyName); dynamic.Children.Add(fromAnimation); } } return(dynamic); }
// OK 140509 // --------------------------------------------------------------- // Date 190209 // Purpose Get a child element with a name. // Entry oElement - Parent (root). // sElementName - The name of the child // Return The child element with the name. // Comments Example (Page is root, Canvas is child): // <Page> // <Canvas x:Name="CNV_00" Width="240" Height="240"> // ... // </Canvas> // </Page> // --------------------------------------------------------------- private FrameworkElement GetItemElement(FrameworkElement oElement, string sElementName) { return (FrameworkElement)oElement.FindName(sElementName); }
public static object GetBoundMember(FrameworkElement element, string name) { return (object) element.FindName(name) ?? OperationFailed.Value; }