Here is my Solution explorer:

enter image description here

I want to make this:

ResourceDictionary dictionary = new ResourceDictionary();
dictionary.Source = new Uri("../Themes/Generic.xaml", UriKind.RelativeOrAbsolute);
Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary());

in the constructor of PageWithoutMaster.

I get error: Cannot locate resource 'themes/style/master.xaml'

What am I doing wrong? Why is it adding the style folder in the path?

As dkozl pointed out, you can fix this by using a Pack URI and including the assembly name in your path

Assuming your resource file looks something like this:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:local="clr-namespace:WpfApp4.Themes">
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/Style/Master.xaml" />
    </ResourceDictionary.MergedDictionaries>
</ResourceDictionary>

Get your assembly name from your project properties:

enter image description here

Then update to this value instead:

<ResourceDictionary Source="WpfApp4;component/Style/Master.xaml" />