Silverlight ControlTemplate and F#

Posted by akaphenom on Stack Overflow See other posts from Stack Overflow or by akaphenom
Published on 2010-05-24T19:27:53Z Indexed on 2010/05/24 19:31 UTC
Read the original article Hit count: 431

Filed under:
|
|

Has anybody had any success incorporating a Silverlight ControlTemplate into an F# Silverlight application. I am trying to add transitions to the Navgiation.Frame element and following along on with a C# example: http://www.davidpoll.com/2009/07/19/silverlight-3-navigation-adding-transitions-to-the-frame-control

The downloaded source uses the MSBUILD:Compile option on the template XAML and the file is included as a "Page"... ILDASM doesn't show any object created for the XAML;

In my project I incldued it as a "Resource" (same as I have done for my pages) and referenced it in 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>

the TransitioningFrame.xaml is as follows:

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

My page objects all load their respective xaml with the follwoing code:

type Page1() as this =
    inherit UriUserControl("/FSSilverlightApp;component/Page1.xaml")
    do
        Application.LoadComponent(this, base.uri)

and somewhere in app startup:

let p1 = new Page1()

I donot have a comparable piece for the ControlTemplate - though I was hoping the application object and App.xaml would pull it in magically (as an aside, the reliance on this magic has made setting up a 100% f# silverlight application rather tricky - as nearly all the published articles I find are based around wizards and short cuts - very little on the acual plumbing - ugh).

Any advice or thougts on the subject are appreciated.

© Stack Overflow or respective owner

Related posts about Silverlight

Related posts about silverlight-3.0