LocTable propagation to ContentControl's content via TemplateBinding
Posted: 11 Apr 2024, 14:38
Hello, in Unreal project, I have a problem with propagating LocTable to ContentControl's content. Am I'm missing something or using bad approach?
I have created custom ContentControl called MainLayout which is suppose to represent main screen layout. This control has three dependency properties - HeaderContent, BodyContent and FooterContent. This content control has default style:
In that style I have three ContentControls, each dedicated to hold each container's content. Then I have UserControl which defines content for each of this section. Like this:
As you can see I have a main Grid, which has set LocTable.Id, so the whole scope of the grid references that table. Then I set content for the Header section. Now the problem is, that while outside the layouts:MainLayout control the text gets translated, inside layouts:MainLayout.HeaderContent does not. Content of that ContentControl on which is binded HeaderContent does not have that Id property set. However layouts:MainLayout does have that Id, so If I put some TextBlock inside that default style's ControlTemplate, it works.
Also when I do this, it also works:
Do you know what might be the issue?
I have created custom ContentControl called MainLayout which is suppose to represent main screen layout. This control has three dependency properties - HeaderContent, BodyContent and FooterContent. This content control has default style:
Code: Select all
<Style TargetType="{x:Type layouts:MainLayout}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type layouts:MainLayout}">
<Grid>
....
<ContentControl Focusable="False" Grid.Row="0" Content="{TemplateBinding HeaderContent" />
<ContentControl Focusable="False" Grid.Row="1" Content="{TemplateBinding BodyContent}" />
<ContentControl Focusable="False" Grid.Row="2" Content="{TemplateBinding FooterContent}" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Code: Select all
<Grid noesis:LocTable.Id="LocTableId">
....
<TextBlock Text="{noesis:LocTable 'Title', Key=ScreenTitle}" />
<layouts:MainLayout>
<layouts:MainLayout.HeaderContent>
<Grid>
<TextBlock Text="{noesis:LocTable 'Title', Key=ScreenTitle}" />
</Grid>
</layouts:MainLayout.HeaderContent>
</layouts:MainLayout>
</Grid>
Also when I do this, it also works:
Code: Select all
<ContentControl Focusable="False" Grid.Row="0">
<ContentControl.Content>
<Grid>
<TextBlock Text="{noesis:LocTable 'Title', Key=ScreenTitle}" />
</Grid>
</ContentControl.Content>
</ContentControl>
Do you know what might be the issue?