K
Kirill
Hello,
For those, who read this newsgroup via the browser: I'm sorry about the
repost, but the post does not appear to be on the newsgroup server, and that
could be a reason that I've not received *any* replies.
How do I specify a string with line breaks in a resource dictionary?
Here is what I want:
I'd like to put a string that contains line breaks (or other special
entities), e.g.
or \n, into a resource dictionary. In other words, I'd
like my resouce dictionary to look like:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:System="clr-namespace:System;assembly=mscorlib"
<System:String x:Key="TwoLiner">First line
Second line</System:String>
</ResourceDictionary>
Here is the problem:
when I retrieve that string with
ResourceDictionary _main = (ResourceDictionary)Application.LoadComponent(new
Uri("WpfCustomControlLibrary2;;;component/CustomDictionary.xaml",
UriKind.Relative));
string twoLiner = _main["TwoLiner"] as string;
the line break (
in .xaml) is replaced with ' ' (\32 in C#)
Here is what I found:
- I tried to use a workaround to a similar problem described in
http://social.msdn.microsoft.com/forums/en-US/wpf/thread/621b9169-94d0-4217-808d-e3adbe92d448/
but I could not make it work and always received internal compiler error
'Object reference not set to an instance of an object.' unless I used
attribute syntax like
<src:ResourceString x:Key="TwoLiner" Value="First line
Second line" />
- to solve the internal compiler error, I tried to write a TypeConverter
that can convert from string to ResourceString, but the error still appears.
Although it's somewhat working, I'd like to:
- either use System:String;
- or use ResourceString but specify the string in the dictionary in the
usual - content - way (not as an attribute).
Thank you for any help or ideas!
Kirill.
For those, who read this newsgroup via the browser: I'm sorry about the
repost, but the post does not appear to be on the newsgroup server, and that
could be a reason that I've not received *any* replies.
How do I specify a string with line breaks in a resource dictionary?
Here is what I want:
I'd like to put a string that contains line breaks (or other special
entities), e.g.
or \n, into a resource dictionary. In other words, I'd
like my resouce dictionary to look like:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:System="clr-namespace:System;assembly=mscorlib"
<System:String x:Key="TwoLiner">First line
Second line</System:String>
</ResourceDictionary>
Here is the problem:
when I retrieve that string with
ResourceDictionary _main = (ResourceDictionary)Application.LoadComponent(new
Uri("WpfCustomControlLibrary2;;;component/CustomDictionary.xaml",
UriKind.Relative));
string twoLiner = _main["TwoLiner"] as string;
the line break (
in .xaml) is replaced with ' ' (\32 in C#)
Here is what I found:
- I tried to use a workaround to a similar problem described in
http://social.msdn.microsoft.com/forums/en-US/wpf/thread/621b9169-94d0-4217-808d-e3adbe92d448/
but I could not make it work and always received internal compiler error
'Object reference not set to an instance of an object.' unless I used
attribute syntax like
<src:ResourceString x:Key="TwoLiner" Value="First line
Second line" />
- to solve the internal compiler error, I tried to write a TypeConverter
that can convert from string to ResourceString, but the error still appears.
Although it's somewhat working, I'd like to:
- either use System:String;
- or use ResourceString but specify the string in the dictionary in the
usual - content - way (not as an attribute).
Thank you for any help or ideas!
Kirill.