2010-05-24 1 views
0

(응용 프로그램 리소스가 올바르게로드되는지 디버거를 통해 알 수있는 방법) 나는 (F #에서) 시도했다.ResourceDictionary가 올바르게로드되었는지 확인하는 방법

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

그것은 0의 카운트를 반환한다. App.xaml 내에서 경로를 변경하면 런타임에 예외가 발생하므로 애플리케이션에서 리소스를로드하고 있음을 확신합니다. 기타 다시, lavent 조각이 : 나는 다음과 같은 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> 

및 콘텐츠 템플릿 한

:

<

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

답변

1

보고 사전을 통합로드, 사용 디버거보기 창 또는 보려는 코드 :

리소스 사전로드 할 나타나지 않는 경우210

, 그것은

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

귀하의 구문은 FSSilverlightApp라는 이름의 어셈블리에 대한 올바른 보이는, 그리고 ... 당신이에 전달하는 소스 경로에 문제가 될 수 TransitioningFrame.xaml 파일이 프로젝트/어셈블리 루트에 있으므로 XAML 파일이 해당 위치에 있는지 확인하십시오.

동일한 어셈블리에서 리소스 사전을로드하는 경우 "어셈블리; component/"구문없이 상대 경로를 사용하십시오. 난 항상에서 ...

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

행운과 같이 leadingh 슬래시없이
짐 맥 커디, YinYangMoney과 얼굴에를 자산 폴더 (실버 라이트 템플릿 규칙) 내 리소스 사전을 넣고 파일을 참조 Face Software

+0

VS2010 rc1 내부의 f # 응용 프로그램 폴더는별로 지원되지 않습니다. 포인터를 주셔서 감사합니다 그 재산을 두 번 확인하고 그것이로드되는지 확인합니다. – akaphenom