こんにちは私はリソースの画像にアクセスする際に問題があります。 Frist私は1つのPNGイメージ(心臓の名前)をリソースに追加します。リソース/ WPFからの画像へのアクセスに問題がある
では、静的リソースとしてXAMLにリソースを配置しています。
<Application x:Class="Spirit.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Spirit.BootStraper"
xmlns:Converters="clr-namespace:Spirit.Converters"
xmlns:Controls="clr-namespace:Spirit.Controls"
xmlns:props="clr-namespace:Spirit.Properties" >
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary>
<local:MefBootStrapper x:Key="bootstrapper" />
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
<props:Resources x:Key="Res"/>
</ResourceDictionary>
</Application.Resources>
</Application>
And use on image from resources on image source.
<Image Name="TroubleImage"
Style="{StaticResource InfoIcon}"
Source="{Binding Source={StaticResource Res},
Path=heart,
Converter={StaticResource imageToGrayConverter}}">
If I run app I get this error:
'Spirit.Properties.Resources'タイプに一致するコンストラクタが見つかりませんでした。 ArgumentsメソッドまたはFactoryMethodディレクティブを使用して、この型を構築できます。
at System.Windows.Markup.XamlReader.RewrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri)
at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
at Spirit.Views.ChatView.InitializeComponent() in c:\Users\Jan\Documents\Visual Studio 2010\Projects\C#\Pokec_Messenger_Project\Pokec_Messenger\Spirit_Caliburn_Micro_v1.0\Views\ChatView.xaml:line 1
at Spirit.Views.ChatView..ctor() in C:\Users\Jan\Documents\Visual Studio 2010\Projects\C#\Pokec_Messenger_Project\Pokec_Messenger\Spirit_Caliburn_Micro_v1.0\Views\ChatView.xaml.cs:line 23
何が悪いですか?
編集:
ChatView.XAML
<Window x:Class="Spirit.Views.ChatView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Controls="clr-namespace:Spirit.Controls"
xmlns:Micro="clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro"
Icon="/Spirit;component/Images/Logo/Icons/Ico/32.ico"
Height="545" Width="763"
Background="{StaticResource LightGrayBackground}">
<Grid Margin="4,4,4,4">
<Grid Grid.Column="1" Margin="2,2,2,2">
<Grid.RowDefinitions>
<!--<RowDefinition Height="{Binding ElementName=InfoExpander,
Path=IsExpanded, Converter={StaticResource expandedToGridLengthConverter}}"
MaxHeight="220"/>-->
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="25"></RowDefinition>
<RowDefinition Height="80"></RowDefinition>
</Grid.RowDefinitions>
<Image Name="TroubleImage"
Style="{StaticResource InfoIcon}"
Source="{Binding Source={StaticResource Res},
Path=heart,
Converter={StaticResource imageToGrayConverter}
}"/>
</Grid>
</Grid>
</Window>
をchatview.xamlにおけるライン23上のパス=心臓画像の名前は、ここで
をheart.png私の資源からの画面ですされます私は何が悪いのか分からないのですか?
http://i51.tinypic.com/14wrbs1.jpg
は私がライン23上で私の質問を編集しましたが、パス=心 –
こんにちは、私は<小道具を追加します>チャットウィンドウのリソースで、私は以前と同じエラーが発生します:{。 –
私は解決策を追加しました。 –