Typically, a resource is a common "single instance", and the various XAML elements refer to one common instance. I'm not sure why the Designer suggests that this will work (except for his legacy in supporting several types of "XAML"). In the case of TextBlock , although this is slightly different, since you want the Element instance to be replicated and created several times (it may be placed in several ContentControl , for example).
WPF had a function to do this work in the special x:Shared attribute. You must set this value to false to indicate that the Resource not been split and that each resource request should return a new instance. WinRT does not have the same function.
However, you might think about supported work.
One option is to use a template instead of replacing the content directly, as you tried:
<Page.Resources> <Style x:Name="replacement" TargetType="ContentControl"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="ContentControl"> <TextBlock FontSize="100" Foreground="Red">Hello!</TextBlock> </ControlTemplate> </Setter.Value> </Setter> </Style> </Page.Resources> <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <ContentControl Style="{StaticResource replacement}"></ContentControl> </Grid>
Syntactically, this is a little longer, but functionally, it should be the same results.
Without x:Shared you are limited by the ability to bind to resources, which are internal data types, for example x:string (as shown in the example below):
<Page.Resources> <x:String x:Key="tbResource">The Text!</x:String> </Page.Resources> <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" > <ContentControl Content="{StaticResource tbResource}" ></ContentControl> </Grid>
source share