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 (xamlFileProjectPath == null)
xamlFileProjectPath = "/Designer/Fake.xaml";
xamlFileProjectPath = "/Fake.xaml";
//Fabricate fake Uri
baseUri =
new Uri($"avares://{Path.GetFileNameWithoutExtension(assemblyPath)}{xamlFileProjectPath}");
@ -43,7 +43,7 @@ namespace Avalonia.DesignerSupport
{
LocalAssembly = localAsm,
DesignMode = true,
UseCompiledBindingsByDefault = bool.TryParse(useCompiledBindings, out var parsedValue ) && parsedValue
UseCompiledBindingsByDefault = bool.TryParse(useCompiledBindings, out var parsedValue) && parsedValue
});
var style = loaded as IStyle;
var resources = loaded as ResourceDictionary;
@ -90,14 +90,14 @@ namespace Avalonia.DesignerSupport
};
}
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
control = (Control) loaded;
control = (Control)loaded;
window = control as Window;
if (window == null)
{
window = new Window() {Content = (Control)control};
window = new Window() { Content = (Control)control };
}
if (window.PlatformImpl is OffscreenTopLevelImplBase offscreenImpl)

Loading…
Cancel
Save