Ray Burns StaticResource , , . - T4 "" xaml , CurrentCulture.
base_block.tt. , , - = "" ( , Utf-8 , XamlParser , Utf-8, -, - ).
<#@ template debug="false" hostspecific="false" language="C#" #>
<#@ output extension=".xaml" encoding="Unicode"#>
<UserControl
xml:lang="<#= this.xml_lang #>"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="basic_styles.xaml" />
<ResourceDictionary Source="equations.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<WrapPanel Style="{StaticResource description_wrap_panel_style}">
<TextBlock x:Name="c_textblock"
Style="{StaticResource description_textblock_style}"
AutomationProperties.Name = "<#= this.textblock_automation_name #>">
<#= this.textblock_constant_C_contents #>
</TextBlock>
<TextBlock Style="{StaticResource description_textblock_style}"
KeyboardNavigation.TabIndex="1">
<#= this.hyperlink_textblock_contents #>
</TextBlock>
<TextBox Style="{StaticResource entry_textbox_style}"
AutomationProperties.LabeledBy="{Binding ElementName=c_textblock}"
KeyboardNavigation.TabIndex="0">
</TextBox>
</WrapPanel>
</UserControl>
<#+
private string xml_lang = @"";
private string textblock_constant_C_contents = @"";
private string textblock_automation_name = @"";
private string hyperlink_textblock_contents = @"";
#>
base_block.tt include .tt, . en.tt, en.xaml:
<
xml_lang = @"en-US";
textblock_constant_C_contents =
@"Enter a constant, <Italic>C</Italic>, that satisfies
<InlineUIContainer Style='{StaticResource image_container_style}'>
<Image x:Name='formula_11' Source='{StaticResource equation_11}' Style='{StaticResource image_style}' Tag='3.0'>
<Image.Height>
<MultiBinding Converter='{StaticResource image_size}'>
<Binding Mode='OneWay' ElementName='formula_11' Path='Tag'/>
<Binding Mode='OneWay' ElementName='c_textblock' Path='FontSize'/>
</MultiBinding>
</Image.Height>
</Image>
</InlineUIContainer>";
textblock_automation_name = @"Enter a Constant, C, that satisfies the following equation: the standard error of the estimate is equal to the constant C over the square root of the sample size";
hyperlink_textblock_contents = @"(<Hyperlink AutomationProperties.Name='More information about the constant C'
x:Name='c_hyperlink'>more info</Hyperlink>)";
<
- fr.tt → fr.xaml:
<
xml_lang = @"fr";
textblock_constant_C_contents =
@"Entrez une constante, <Italic>C</Italic>, pour satisfaire
<InlineUIContainer Style='{StaticResource image_container_style}'>
<Image x:Name='formula_11' Source='{StaticResource equation_11}' Style='{StaticResource image_style}' Tag='3.0'>
<Image.Height>
<MultiBinding Converter='{StaticResource image_size}'>
<Binding Mode='OneWay' ElementName='formula_11' Path='Tag'/>
<Binding Mode='OneWay' ElementName='c_textblock' Path='FontSize'/>
</MultiBinding>
</Image.Height>
</Image>
</InlineUIContainer>";
textblock_automation_name = @"Entrez une constante, C, qui satisfait l'équation suivante: l'erreur-type de l'estimation est égale à la constante C sur la racine carrée de la taille de l'échantillon.";
hyperlink_textblock_contents = @"(<Hyperlink AutomationProperties.Name=""Plus d'informations sur la constante C"">en savoir plus</Hyperlink>)";
<
French creates the following .xaml file:
<UserControl
xml:lang="fr"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="basic_styles.xaml" />
<ResourceDictionary Source="equations.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<WrapPanel Style="{StaticResource description_wrap_panel_style}">
<TextBlock x:Name="c_textblock"
Style="{StaticResource description_textblock_style}"
AutomationProperties.Name = "Entrez une constante, C, qui satisfait l'équation suivante: l'erreur-type de l'estimation est égale à la constante C sur la racine carrée de la taille de l'échantillon.">
Entrez une constante, <Italic>C</Italic>, pour satisfaire
<InlineUIContainer Style='{StaticResource image_container_style}'>
<Image x:Name='formula_11' Source='{StaticResource equation_11}' Style='{StaticResource image_style}' Tag='3.0'>
<Image.Height>
<MultiBinding Converter='{StaticResource image_size}'>
<Binding Mode='OneWay' ElementName='formula_11' Path='Tag'/>
<Binding Mode='OneWay' ElementName='c_textblock' Path='FontSize'/>
</MultiBinding>
</Image.Height>
</Image>
</InlineUIContainer>
</TextBlock>
<TextBlock Style="{StaticResource description_textblock_style}"
KeyboardNavigation.TabIndex="1">
(<Hyperlink AutomationProperties.Name="Plus d'informations sur la constante C">en savoir plus</Hyperlink>)
</TextBlock>
<TextBox Style="{StaticResource entry_textbox_style}"
AutomationProperties.LabeledBy="{Binding ElementName=c_textblock}"
KeyboardNavigation.TabIndex="0">
</TextBox>
</WrapPanel>
</UserControl>
At runtime, I look at CurrentCulture, compare it with the generated xaml files that are available, pass the XamlReader.Load () file, and add the resulting Usercontrol where necessary. A small sample application demonstrating this is available here .