void XamlUpdater() { if (!_initSuccess) { return; } if (_lastXaml == _currentXaml) { return; } _lastXaml = _currentXaml; if (!ValidateXml(_currentXaml)) { _appModel.SetError("Invalid markup"); return; } try { Api.UpdateXaml(_currentXaml); _appModel.SetError(null); } catch (Exception e) { _appModel.SetError("XAML load error", e.ToString()); } }
void XamlUpdater() { if (!_initSuccess) { return; } if (_lastXaml == _currentXaml) { return; } _lastXaml = _currentXaml; if (!ValidateXml(_currentXaml)) { _appModel.SetError("Invalid markup"); return; } try { const string windowType = "Perspex.Controls.Window"; var root = _xamlReader(new MemoryStream(Encoding.UTF8.GetBytes(_currentXaml))); dynamic window = root; if (root.GetType().FullName != windowType) { window = Activator.CreateInstance(LookupType(windowType)); window.Content = root; } var w = ((object)(window.PlatformImpl)).Prop("Handle"); if (!(w is IntPtr)) { w = w.Prop("Handle"); } var hWnd = (IntPtr)w; _appModel.NativeWindowHandle = hWnd; window.Show(); _appModel.SetError(null); } catch (Exception e) { _appModel.SetError("XAML load error", e.ToString()); } }