I am writing a multilanguage application. So each text for output (in C#-Code and in XAML too) has to be held in (Language-)ResourceDictionary. This works fine with plain text. E.g:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="clr-namespace:System;assembly=mscorlib"
>
<s:String x:Key="TextOfTbl7Key">This is the all plain text of TextBlock7 in English</s:String>
...
...
</ResourceDictionary>
<Window x:Class="MyAppl.Windows.Dialog17"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
.....
<TextBlock Text="{DynamicResource TextOfTbl7Key}"/>;
...
...
</Grid>
</Window>
But what, if the TextBlock with text to extract contains formatted Text, i.e. the TextBlock has Inlines:
<TextBlock Name="Tbl8">
Normal stuff, something very <Bold>important</Bold>, and a <Italic>Name</Italic> of something.
</TextBlock>
What I want is to export this as a single ... (whatever - but string does not work). No solution is to divide the text in many textparts (with own keys), because the composition of the text will depend on the language (And this solution would be ugly too). One solution could be to hold the entire TextBlock as a resource in the ResourceDictionary this way:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="clr-namespace:System;assembly=mscorlib"
>
<s:String x:Key="TextOfTbl7Key">This is boring text of TextBlock7 in English</s:String>
<TextBlock x:Key="Tbl8Key">Normal stuff, something very <Bold>important</Bold>, and a <Italic>Name</Italic> of something </TextBlock>
...
...
</ResourceDictionary>
But I have no idea how to access the Resource-TextBlock as an Elemnet in XAML.
<Window x:Class="MyAppl.Windows.Dialog17"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
.....
<TextBlock Text="{DynamicResource TextOfTbl7Key}"/>;
...
...
</Grid>
</Window>
Thanks for your answers in advance.