WPF Resource Dictionary not found with IronPython (pyRevit Revit addin development)

73 views Asked by At

I am working through learning XAML, and I'm trying to learn how to use a Resource Dictionary to keep my styles consistent across different UIs. I have gotten to this point where I have defined a simple resource dictionary like this:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ControlTemplate x:Key="buttonTemplate" TargetType="{x:Type Button}">
    <Border Background="Red"
            BorderBrush="{TemplateBinding BorderBrush}"
            BorderThickness="{TemplateBinding BorderThickness}"
            CornerRadius="50">
        <ContentPresenter HorizontalAlignment="Center"
                          VerticalAlignment="Center" />
    </Border>
</ControlTemplate>

and my UI xaml file looks like this:

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="200" Height="200" Topmost="True">
<Window.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="../../../../../folder with resource dictionary/xamlStyles.xaml"/>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Window.Resources>
<!--Rest of UI below-->

My resource dictionary lives 5 folder levels up from my UI.xaml file due to the platform I'm working within (pyRevit. A python interface for building custom tools in Autodesk Revit).

When I run my code that shows this XAML window, I get the following error:

System.IO.IOException: Cannot locate resource 'folder with resource dictionary/xamlstyles.xaml'.

I have also tried putting the dictionary in the same folder as my ui.xaml file and removing the "../../../../../folder with resource dictionary/" portion from the Source and it still can't find the file.

I imagine that the issue has something to do with how pyRevit works. I am not actually compiling a WPF app. I just have IronPython scripts that open a xaml window

0

There are 0 answers