views:

24

answers:

1

Hi,

I have a userControl like this:

<UserControl x:Class="LoginModule.LoginView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:controls="clr-namespace:UserControls;assembly=UserControls"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >

    <UserControl.Resources>
          <ResourceDictionary Source="pack://application:,,,/UserControls;component/Styles.xaml" />
    </UserControl.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="30" />
            <RowDefinition Height="30" />
            <RowDefinition Height="30" />
            <RowDefinition Height="40" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="200" />
            <ColumnDefinition Width="200" />
        </Grid.ColumnDefinitions>

        <Label Grid.Row="1" Grid.Column="0" Name="labelLogin" VerticalAlignment="Center">Login:</Label>
        <Label Grid.Row="2" Grid.Column="0" Name="labelPassword" VerticalAlignment="Center">Password:</Label>

        <TextBox Grid.Row="1" Grid.Column="1" Name="textboxLogin" VerticalAlignment="Center"></TextBox>
        <TextBox Grid.Row="2" Grid.Column="1" Name="textboxPassword" VerticalAlignment="Center"></TextBox>

        <Button Grid.Row="3" Grid.ColumnSpan="2" Template="{StaticResource SilverButton}" Height="25" Width="200" Name="buttonLogin" Content="Log In" Click="buttonLogin_Click" />
    </Grid>
</UserControl>

In designer mode everything is ok (style works), all solution building with success. But when I run program with debug I get XamlParserException in:

<ResourceDictionary Source="pack://application:,,,/UserControls;component/Styles.xaml" />

with message like: Could not load UserControl oir one of his elements. Could not load file. I have reference to UserControl.dll I don't know what's going on.

Thanks for any fast help. Kamilos

A: 

I think this is because you need to use merged dictionaries:

<UserControl.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="pack://application:,,,/YourAssembly;component/YourResource.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</UserControl.Resources>
Steve Greatrex
nope, got the same
Kamilos
could you add the exact error message you get to your post?
Steve Greatrex