How to force VS to react on a changing of an attached property in design time?

Posted by sedovav on Stack Overflow See other posts from Stack Overflow or by sedovav
Published on 2010-06-03T12:31:25Z Indexed on 2010/06/03 12:34 UTC
Read the original article Hit count: 193

Imagine, we have a wpf class library with a window1.xaml and a resource dictionary res.xaml defined in it. I know how to use styles that defined in the res.xaml for the controls that defined into the window:

<Window x:Class="...Window1">
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="res.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    <\Window.Resources>
</Window>

So we can use the dictionary's styles for all elements into the window (except the window element... I don't know how to set the style from the res.xaml for the window :( ). I saw the article where describes how to create and use attached property to add resource dictionaries to a FrameworkElement.Resources.MergedDictionaries list. It's good! We can do the same as we done in the example above but we can use the window style now. It looks like this:

<Window x:Class="...Window1"
           xmlns: resources="..."
           resources:SharedResources.MergedDictionaries="res.xaml">
</Window>

That's good but VS2008 cannot recognize resources from res.xaml in design time. So we have a sad situation: all styles from res.xaml are available in run-time but in the design-time VS cannot display the window (it can't find the mentioned styles). Does anybody know how to fix this situation?

© Stack Overflow or respective owner

Related posts about wpf

Related posts about design-time