tags:

views:

662

answers:

2

I'm searching how to skin an application with a complex resource: I have a skin file in which I put canvas, with images other canvas something like whis:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" >
<Style x:Key="MainBackground" TargetType="{x:Type Canvas}">
<Setter Property="Canvas">
<Setter.Value>
 <Canvas Width="1440.000" Height="900.000" >
</Canvas>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>

How can I load this skin in the main app? something like:

<Window >
    <Canvas  Style = "{StaticResource  MainBackground}">

    </Canvas>
</Window >
+1  A: 

First of all, don't use a Canvas to lay out controls explicitly. Use the other Panel types (such as Grid and DockPanel).

Secondly, you can import a ResourceDictionary like this:

<Window>
    <Window.Resources>
        <ResourceDictionary Source="YourDictionary.xaml"/>
    </Window.Resources>
</Window>

Or you can merge in multiple ResourceDictionarys as follows:

<Window>
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="YourDictionary.xaml"/>
                <ResourceDictionary Source="YourOtherDictionary.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>

        <SolidColorBrush x:Key="SomeLocalResource">Red</SolidColorBrush>
    </Window.Resources>
</Window>

HTH, Kent

Kent Boogaart
My question is a little different: I've a xaml file (converted from a AI) that is a vector image converted full of canvas and other polyline... I want to use this as background.
Mic.
This answer does not address the original question.
emddudley
A: 

If I understood the question correctly: You can create a visual brush from the exported XAML file's root visual, and use it as the brush of another canvas.

Ugur Turan