コード例 #1
0
 public IEnumerable <KeyValuePair <string, object> > GetAllNamesAndValuesInScope()
 {
     System.Windows.NameScope nameScopes = this.nameScope as System.Windows.NameScope;
     if (nameScopes != null)
     {
         return(nameScopes);
     }
     return(Enumerable.Empty <KeyValuePair <string, object> >());
 }
コード例 #2
0
ファイル: ControlHost.cs プロジェクト: ssethi/TestFrameworks
        public ControlHost()
        {
            var stack = new StackPanel();
            Content = stack;

            _param1 = new TextBox {Name = "param1"};
            _param2 = new TextBox {Name = "param2"};

            stack.Children.Add(_param1);
            stack.Children.Add(_param2);

            _scope = new NameScope();

            NameScope.SetNameScope(this, _scope);

            _scope.RegisterName("param1", _param1);
            _scope.RegisterName("param2", _param2);

            _methodResult = new TextBox {Name = "MethodResult"};
            _scope.RegisterName("MethodResult", _methodResult);
        }
コード例 #3
0
ファイル: Transition.cs プロジェクト: Ghawken/FrontView
		protected NameScope GetNameScope()
		{
			var scope = new NameScope();
			NameScope.SetNameScope(Owner.TransitionContainer, scope);
			return scope;
		}
コード例 #4
0
		public void OnPlotterAttached(Plotter plotter)
		{
			if (Parent == null)
			{
				hostPanel = new ViewportHostPanel();
                Viewport2D.SetIsContentBoundsHost(hostPanel, false);
				hostPanel.Children.Add(this);

				plotter.Dispatcher.BeginInvoke(() =>
				{
					plotter.Children.Add(hostPanel);
				}, DispatcherPriority.Send);
			}
#if !old
			Canvas hostCanvas = (Canvas)hostPanel.FindName(canvasName);
			if (hostCanvas == null)
			{
				hostCanvas = new Canvas { ClipToBounds = true };
				Panel.SetZIndex(hostCanvas, 1);

				INameScope nameScope = NameScope.GetNameScope(hostPanel);
				if (nameScope == null)
				{
					nameScope = new NameScope();
					NameScope.SetNameScope(hostPanel, nameScope);
				}

				hostPanel.RegisterName(canvasName, hostCanvas);
				hostPanel.Children.Add(hostCanvas);
			}

			hostCanvas.Children.Add(this);
#else
#endif

			Plotter2D plotter2d = (Plotter2D)plotter;
			this.plotter = plotter2d;
		}
コード例 #5
0
        // Call various interfaces on the passed element during initialization or
        // creation of the element.  This is usually called immediately after 
        // creating the object.
        // The bamlElementStartRecord may be null.   If it isn't, it represents the 
        // record that caused this object to be created. 

        private bool ElementInitialize(object element, string name) 
        {
            bool result = false; // returns true if need to do EndInit()

            // Tell the Element Initialization has begun and hence postpone the Initialized event 
            // If the element implements ISupportInitialize, call it.
            ISupportInitialize supportInitializeElement = element as ISupportInitialize; 
            if (supportInitializeElement != null) 
            {
                if( TraceMarkup.IsEnabled ) 
                {
                    TraceMarkup.Trace( TraceEventType.Start,
                                     TraceMarkup.BeginInit,
                                     supportInitializeElement ); 
                }
 
                supportInitializeElement.BeginInit(); 
                result = true;
 
                if( TraceMarkup.IsEnabled )
                {
                    TraceMarkup.Trace( TraceEventType.Stop,
                                     TraceMarkup.BeginInit, 
                                     supportInitializeElement );
                } 
 
            }
 
            // If this is an element start record that carries its name also, then register the name now.

            if (name != null)
            { 
                DoRegisterName(name, element);
            } 
 

            // Tell element its base uri 
            IUriContext uriContext = element as IUriContext;
            if (uriContext != null)
            {
                uriContext.BaseUri = GetBaseUri(); 
            }
            else 
            { 
                // Set the ApplicationMarkupBaseUri if this is for AppDef baml stream.
                if (element is Application) 
                {
                    ((Application)element).ApplicationMarkupBaseUri = GetBaseUri();
                }
            } 

            UIElement uiElement = element as UIElement; 
            if (uiElement != null) 
            {
                uiElement.SetPersistId(++_persistId); 
            }

            // The second consition is to handle events within standalone dictionaries.
            // We need to setup the component connector correctly in this case. Note 
            // that the standalone dictionary is preceded by a DictionaryHolder.
            if (CurrentContext == null) 
            { 
                IComponentConnector icc = null;
                if (_componentConnector == null) // why was this necessary? 
                {
                    _componentConnector = icc = element as IComponentConnector;
                    if (_componentConnector != null)
                    { 
                        if (ParserContext.RootElement == null)
                        { 
                            ParserContext.RootElement = element; 
                        }
 
                        // Connect the root element.
                        _componentConnector.Connect(0, element);
                    }
                } 

                _rootElement = element; 
 
                DependencyObject doRoot = element as DependencyObject;
                if (!(element is INameScope) 
                    && ParserContext.NameScopeStack.Count == 0
                    && (doRoot != null))
                {
                    NameScope namescope = null; 
                    // if the root element is markup sub-classed and already is a namescope, use it.
                    if (icc != null) 
                    { 
                        namescope = NameScope.GetNameScope(doRoot) as NameScope;
                    } 
                    if (namescope == null)
                    {
                        namescope = new NameScope();
                        NameScope.SetNameScope(doRoot, namescope); 
                    }
                } 
 
                if (doRoot != null)
                { 
                    Uri baseuri = GetBaseUri();
                    SetDependencyValue(doRoot, BaseUriHelper.BaseUriProperty, baseuri);
                }
            } 

            return result; 
        } 
コード例 #6
0
 private static FrameworkElement GetResolvedTarget(FrameworkElement target, string targetName, BaseValueSource valueSource)
 {
     return(targetName.IsNullOrEmpty() ? target : (valueSource == BaseValueSource.Local ? NameScope.GetContainingNameScope(target) : NameScope.GetTemplateNameScope(target)).FindName(targetName) as FrameworkElement);
 }