views:

69

answers:

1

How can I tell (through the debugger if my app resources are being loaded correctly). I have tried (in f#)

type MyApp() as this =
    inherit Application() 
        do Application.LoadComponent(this, new System.Uri("/FSSilverlightApp;component/App.xaml", System.UriKind.Relative))  

    let cc = new ContentControl()

    let mainGrid : Grid = loadXaml("MainWindow.xaml")
    let siteTemplate : Grid = mainGrid 

    let txt : TextBlock = siteTemplate ? txt

    do
        this.Startup.Add(this.startup)
        let mutable s = "Items: "
        s <- s + this.Resources.Count.ToString()

it is returning a count of zero. Though I am pretty sure the application is loading the resource because if I change the path within the App.xaml - I get exceptions at runtime. Other re,lavent snippets are:

I have the following app.xaml

<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
             x:Class="Module1.MyApp">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/FSSilverlightApp;component/TransitioningFrame.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
</Application>

and content template:

<

ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"  
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt;
    <ControlTemplate x:Key="TransitioningFrame" TargetType="navigation:Frame">
        <Border Background="{TemplateBinding Background}"
                BorderBrush="{TemplateBinding BorderBrush}"
                BorderThickness="{TemplateBinding BorderThickness}"
                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
            <ContentPresenter Cursor="{TemplateBinding Cursor}"
                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                          Margin="{TemplateBinding Padding}"
                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                          Content="{TemplateBinding Content}"/>
        </Border>
    </ControlTemplate>
</ResourceDictionary>
A: 

To see which merged dictionaries are loaded, use a debugger watch window or code to look at:

Application.Current.Resources.MergedDictionaries.Count
Application.Current.Resources.MergedDictionaries[0].Count
etc...

If your resource dictionary does not appear to be loading, it could be a problem with the Source path you pass into...

<ResourceDictionary Source="/FSSilverlightApp;component/TransitioningFrame.xaml" />

Your syntax looks correct for an assembly named FSSilverlightApp, and for a TransitioningFrame.xaml file at the project/assembly root, so be sure that your XAML file is at that location.

If you are loading a resource dictionary from the same assembly, just use the relative path without the "assembly;component/" syntax. I always put my resource dictionaries in an Assets folder (the Silverlight templates convention) and refer to the files without the leadingh slash, as in...

<ResourceDictionary Source="Assets/Styles.xaml" />

Good luck,
Jim McCurdy, YinYangMoney and Face to Face Software

Jim McCurdy
Not much support for folders in f# application inside VS2010 rc1. Thanks for the pointers I will double check that property and see if it is loading.
akaphenom