Browse Source

fix: AvaloniaVS can not resolve resource relative path in Previewer

pull/12473/head
Giuseppe Lippolis 3 years ago
parent
commit
8720fc9c27
  1. 10
      src/Avalonia.DesignerSupport/DesignWindowLoader.cs

10
src/Avalonia.DesignerSupport/DesignWindowLoader.cs

@ -29,7 +29,7 @@ namespace Avalonia.DesignerSupport
if (assemblyPath != null) if (assemblyPath != null)
{ {
if (xamlFileProjectPath == null) if (xamlFileProjectPath == null)
xamlFileProjectPath = "/Designer/Fake.xaml"; xamlFileProjectPath = "/Fake.xaml";
//Fabricate fake Uri //Fabricate fake Uri
baseUri = baseUri =
new Uri($"avares://{Path.GetFileNameWithoutExtension(assemblyPath)}{xamlFileProjectPath}"); new Uri($"avares://{Path.GetFileNameWithoutExtension(assemblyPath)}{xamlFileProjectPath}");
@ -43,7 +43,7 @@ namespace Avalonia.DesignerSupport
{ {
LocalAssembly = localAsm, LocalAssembly = localAsm,
DesignMode = true, DesignMode = true,
UseCompiledBindingsByDefault = bool.TryParse(useCompiledBindings, out var parsedValue ) && parsedValue UseCompiledBindingsByDefault = bool.TryParse(useCompiledBindings, out var parsedValue) && parsedValue
}); });
var style = loaded as IStyle; var style = loaded as IStyle;
var resources = loaded as ResourceDictionary; var resources = loaded as ResourceDictionary;
@ -90,14 +90,14 @@ namespace Avalonia.DesignerSupport
}; };
} }
else if (loaded is Application) else if (loaded is Application)
control = new TextBlock {Text = "Application can't be previewed in design view"}; control = new TextBlock { Text = "Application can't be previewed in design view" };
else else
control = (Control) loaded; control = (Control)loaded;
window = control as Window; window = control as Window;
if (window == null) if (window == null)
{ {
window = new Window() {Content = (Control)control}; window = new Window() { Content = (Control)control };
} }
if (window.PlatformImpl is OffscreenTopLevelImplBase offscreenImpl) if (window.PlatformImpl is OffscreenTopLevelImplBase offscreenImpl)

Loading…
Cancel
Save