public IUIObject?CreateElement() { if (TryGetFrameworkElement(out var el)) { return(ElementMapper.Create(el)); } return(TryGetFrameworkContentElement(out var ce) ? ElementMapper.Create(ce) : null); }
private static void OnEventsChanged(Control d, string newValue, string?oldValue) { var ele = ElementMapper.Create(d); var rootOption = ControlBindLogic.FindRoot(ele.AsOption()); rootOption.Run( root => BindInternal(oldValue, newValue, root, ele), () => ControlBindLogic.MakeLazy((IUIElement)ele, newValue, oldValue, BindInternal)); }
protected override void Scan() { var realName = Name; string?windowName = null; if (realName.Contains(":")) { var nameSplit = realName.Split(new[] { ':' }, 2); realName = nameSplit[0]; windowName = nameSplit[1]; } var priTarget = ((WpfObject)AffectedObject).DependencyObject; if (windowName == null) { if (!(priTarget is System.Windows.Window)) { priTarget = System.Windows.Window.GetWindow(priTarget); } if (priTarget == null) { LogManager.GetCurrentClassLogger().Error($"ControlHelper: No Window Found: {DataContext.GetType()}|{realName}"); } } else { priTarget = System.Windows.Application.Current.Windows.Cast <System.Windows.Window>() .FirstOrDefault(win => win.Name == windowName); if (priTarget == null) { LogManager.GetCurrentClassLogger().Error($"ControlHelper: No Window Named {windowName} Found"); } } if (priTarget == null) { return; } if (DataContext is IViewModel model && ElementMapper.Create(priTarget) is IUIElement element) { model.AwaitInit(() => model.Actor.Tell(new ControlSetEvent(Name, element))); } }
private static void SetLinker(AvaloniaObject obj, string?oldName, string?newName, Func <LinkerBase> factory) { if (string.IsNullOrWhiteSpace(newName)) { return; } Argument.NotNull(obj, nameof(obj)); Argument.NotNull(factory, nameof(factory)); var ele = ElementMapper.Create(obj); var rootOption = ControlBindLogic.FindRoot(ele.AsOption()); rootOption.Run( root => SetLinker(newName, oldName, root, ele, factory), () => ControlBindLogic.MakeLazy((IUIElement)ele, newName, oldName, (name, old, controllable, dependencyObject) => SetLinker(old, name, controllable, dependencyObject, factory))); }
private static void OnEventsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (DesignerProperties.GetIsInDesignMode(d)) { return; } var ele = ElementMapper.Create(d); var rootOption = ControlBindLogic.FindRoot(ele.AsOption()); rootOption.Run( root => BindInternal(e.OldValue as string, e.NewValue as string, root, ele), () => { if (d is FrameworkElement) { ControlBindLogic.MakeLazy((IUIElement)ele, e.NewValue as string, e.OldValue as string, BindInternal); } }); }
protected Window(IViewModel viewModel) { _element = (IWindow)ElementMapper.Create(this); _controlLogic = new WindowControlLogic(this, viewModel); }
protected UserControl(IViewModel viewModel) { _element = (IUIElement)ElementMapper.Create(this); _controlLogic = new UserControlLogic(this, viewModel); }