2012-01-25 8 views
2

UserControl.Resourcesの使用中に問題があります。私はエラーメッセージが表示される "リソース 'リソース\ Resource.xaml'ファイルは、プロジェクトの一部ではないか 'リソース'プロパティに設定されていない 'ビルドアクション'プロパティが設定されていません。UserControl.Resourcesの使用

フォーラムで検索しましたが、 。私は何とかエラーまだサンプルに記載されている正確に何をやったとリソースに埋め込まれたスタイルは、私のコントロールに適用されることに失敗している以下の私のコードです:

<UserControl x:Class="Client.NavigationControl" 
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      xmlns:local="clr-namespace:Client" 
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      HorizontalAlignment="Left" 
      VerticalAlignment="Top" 
      d:DesignHeight="59" 
      d:DesignWidth="349" 
      mc:Ignorable="d"> 

<UserControl.Resources> 
     <ResourceDictionary> 
      <ResourceDictionary.MergedDictionaries> 
       <ResourceDictionary Source="Resources\Resource.xaml" /> 
      </ResourceDictionary.MergedDictionaries> 
     </ResourceDictionary> 
</UserControl.Resources> 

<Grid Name="grid1" 
      Width="341" 
      Height="54" 
      HorizontalAlignment="Stretch" 
      VerticalAlignment="Stretch"> 


<Button Name="button2" 
       Width="97" 
       Height="35" 
       Margin="106,10,0,0" 
       HorizontalAlignment="Left" 
       VerticalAlignment="Top" 
       Command="{Binding ButtonResponseSection}" 
       CommandParameter="ResponseSection" 
       Content="ResponseSection" 
       Style="{DynamicResource GlassButton}" /> 


    </Grid> 
</UserControl> 

助けてください。 - (..

+0

申し訳ありません。あなたの質問で「あなたのプロジェクトファイルのように見えますか? .. – anevil

答えて

2

Resource.xamlのビルドアクションがPageに設定されていることを確認してください。

また、相対URI "Resources \ Resource.xaml"が正しい場合は参照してください。

URI構文の例として、UserControl NavigationControlがClientという名前空間に存在し、名前空間ClientがAppという名前空間に含まれているとします。 AppにネームスペースResourcesが含まれ、Resource.xamlがこのネームスペースに存在する場合、正しいURIは../Resources/Resource.xamlになります。

+0

答えに感謝します!私はApp.xaml内のリソースへの参照を入れました。どうもありがとう! – anevil

関連する問題