Initialization of 'System.Windows.Setter' threw an exception

2k Views Asked by At

I have recently started a new project using MS Prism. in one of my UI modules, I have resource file which I need to add them to application resource dictionary.. SO I wrote this code to do it:

uri = new Uri(string.Format(@"pack://application:,,,/{0};component/{1}",
                            "namespacename",
                            "Resources.xaml"));
                Application.Current.Resources.MergedDictionaries
                    .Add(new ResourceDictionary
                    {
                        Source = uri,
                    });

In my resource files, I have Setter for Datatemplate which looks like it:

   <DataTemplate.Triggers>
        <DataTrigger Binding="{Binding State}" Value="Modified">
            <Setter TargetName="img" Property="Source" Value="../Images/ICO/Modify.ico"/>
        </DataTrigger>
        <DataTrigger Binding="{Binding State}" Value="Added">
            <Setter TargetName="img" Property="Source" Value="../Images/ICO/Add.ico" />
        </DataTrigger>
    </DataTemplate.Triggers>

the problem is on loading resource file it throws "Initialization of 'System.Windows.Setter' threw an exception." but when I remove this setter, it works fine. Any Idea?

1

There are 1 best solutions below

0
On

Im need to do some test. But you may try change paths to images to absolute path like : pack://application:,,,/{0};component/Images/ICO/Modify.ico