2010-05-24 71 views
0

有沒有人將Silverlight ControlTemplate合併到F#Silverlight應用程序中。我試圖添加轉換到Navgiation.Frame元素,並跟隨一個C#示例:http://www.davidpoll.com/2009/07/19/silverlight-3-navigation-adding-transitions-to-the-frame-controlSilverlight ControlTemplate和F#

下載的源在模板XAML上使用MSBUILD:Compile選項,該文件作爲「頁面」包含在內。 ILDASM不顯示爲XAML創建的任何對象;

在我的項目我incldued它作爲「資源」(同我已經做了我的網頁),並在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> 

的TransitioningFrame.xaml如下:

<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> 

我的頁面對象均加載各自的XAML與follwoing代碼:

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

和somew在這裏應用程序啓動時:

let p1 = new Page1() 

我DONOT有相當部分的控件模板 - 雖然我一直希望的應用對象和App.xaml中會拉它神奇(順便說一句,在這個神奇的依賴已經成立了一個100%f#silverlight應用程序,相當棘手 - 幾乎所有我發現的文章都是基於嚮導和捷徑 - 對於實際的管道很少 - 呃)。

<StackPanel Grid.Row="3" Grid.Column="2" Name="mainPanel"> 
    <navigation:Frame Name="contentFrame" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Template="{StaticResource TransitioningFrame}"/> 
</StackPanel> 

關於這個問題的任何意見或thougts的讚賞:

頁XAML通過引用控制。


每brians評論,我調查了MSBUILD命令診斷和它看起來並不像它anythining除了它作爲一種資源:

生成.resources文件: 「OBJ \ Debug \ TransitioningNavigation.g.resources'... (TaskId:14)正在讀取資源文件: 'C:\ Users \ todd.brown \ Desktop \ TransitioningNavigation \ TransitioningNavigation \ Assets \ Styles.xaml'... (TaskId :14)資源ID是 'assets/styles.xaml'。 (TASKID:14)
讀資源文件: 'C:\用戶\ todd.brown \桌面\ TransitioningNavigation \ TransitioningNavigation \資產\ TransitioningFrame.xaml' ... (TASKID:14)資源ID是 「資產/ transitioningframe.xaml」。 (任務id:14)


好一個有趣的事情是,如果我重新命名參考的App.xaml的XAML的ContentTemplate inide - 應用deosn't負載,並拋出一個錯誤 - 所以我猜測頁面正在被引用並正確加載。即這是不好的

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

回答

0

這可能是去命令行實用,運行

msbuild /t:clean 
msbuild /v:diag > diagnostics.txt 

,檢查診斷日誌,找出「什麼是XAML文件的Compile(與ResourceDictionary)正在引擎蓋下「。這可能暗示爲F#做什麼。

+0

不知道這個功能的...很好的建議-thx。雖然我想知道UI是否應該用手編寫過渡代碼或者喜歡的技術是什麼。它看起來好像TransitioningContentControl只是免費連接了三個轉換。並沒有一個看起來過於複雜。 – akaphenom 2010-05-24 20:01:06

0

好吧,其實我是在WPF 4.0中寫道CONTROLTEMPLATES,所以爲Silverlight這應該差不多工作過,請檢查下面的文章,並且我所提到的git的樞紐源,

http://fadsworld.wordpress.com/2011/03/05/f-wpf-component-development/

你應該幾乎可以瞭解如何聲明資源,將它們與控制模板一起使用,還可以在自定義控件中加載控件模板。我也用這種方式讓BLEND工作。

讓我知道你是否需要任何幫助。

感謝, 法赫德

相關問題