Reputation: 4443
I have ResourceDictionary in my application. I need to add some items from c# code to this collection:
<UserControl.Resources>
<ResourceDictionary>
</ResourceDictionary>
</UserControl.Resources>
As key for resources i want to use path to file. For example:
c:\some folder\@#file.txt
What is the best wey to convert this file path to valid ResourceDictionary Key?
Upvotes: 0
Views: 400
Reputation: 2618
This article on CP tell you how use loose XAML files at Runtime, also some other. Have a look.
Upvotes: 1
Reputation: 35146
<UserControl.Resources>
<ResourceDictionary xmlns:sys="clr-namespace:System;assembly=mscorlib">
<sys:String x:Key="c:some folder#file.txt">
whatever
</sys:String>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<Label Content="{StaticResource c:some folder#file.txt}" />
</Grid>
Remove back slash and encode special characters.
Upvotes: 1