I've got a custom control class in my project called "CarSystemWindow". It descends from Window and has a custom template that gives all windows in my application the same look. It also defines two dependency properties named DeviceName and DeviceType. These are of type string. They default to "Vehicle: " and "Car 54", respectively.

In my main program, I retrieve a row from my database into a View Model object and save that in a normal CLR property called Site during the program's initialization. In the MainWindow's xaml, I have the following code:

```
<cs:CarSystemWindow x:Class="....MainWindow"
                    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:c="clr-namespace:..."
                    xmlns:cs="..."
                    Background="Black" 
                    Closed="Window_Closed" 
                    DataContext="{Binding Path=Site, RelativeSource={RelativeSource AncestorType={x:Type Window}}}" 
                    DeviceName="{Binding Path=SiteName}" 
                    DeviceType="{Binding Path=SiteTypeName}"
                    Icon="..." 
                    Height="600" 
                    Loaded="Window_Loaded" 
                    ResizeMode="CanMinimize" 
                    SourceInitialized="Window_SourceInitialized" 
                    Title="Window Title" 
                    Width="800" 
                    WindowStartupLocation="CenterScreen">

```

At run time, the binding on the DataContext attribute is failing with the following message:

```
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Window', AncestorLevel='1''. BindingExpression:Path=Site; DataItem=null; target element is 'MainWindow' (Name=''); target property is 'DataContext' (type 'Object')

```

I'm using this same binding code elsewhere and it works. I've even turned the Site property into a dependency property and its still failing.

Does anyone give have ideas why the binding is failing?

Thanks

Tony