Hello,
here some xaml:
<
ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:c="clr-namespace:myTest"><
ResourceDictionary.MergedDictionaries><
ResourceDictionary Source="Common.xaml" /></
ResourceDictionary.MergedDictionaries><
Style x:Key="DefaultLayout" TargetType="{x:Type Page}"><
Style.Resources><
ObjectDataProvider x:Key="LayoutData" ObjectType="{x:Type c:DefaultLayoutData}" /><
ScaleTransform x:Key="ScaleTransform" ScaleX="1" ScaleY="1" /></
Style.Resources><
Setter Property="Template"><
Setter.Value><
ControlTemplate TargetType="{x:Type Page}"><
Grid Name="backGrid" Background="{StaticResource PageBackgroundBrush}" LayoutTransform="{StaticResource ScaleTransform}"><
Grid.ColumnDefinitions><
ColumnDefinition Width="*" /><
ColumnDefinition Width="3*" /></
Grid.ColumnDefinitions><
Grid.RowDefinitions><
RowDefinition Height="100" /><
RowDefinition /></
Grid.RowDefinitions>
<
Label Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2" Content="{TemplateBinding Property=Page.Title}"></Label><
Label Name="lblTest" Grid.Column="1" Grid.Row="0"><
Binding Source="{StaticResource LayoutData}" Mode="OneTime" Path="PageSubTitle"/></
Label><!--More Controls-->
</
Grid></
ControlTemplate></
Setter.Value></
Setter></
Style></
ResourceDictionary>How can i access the frm Template generatet Controls in the Page Code behind
Thorsten
Sorry for my bad english.

Access to Template Controls
joe.hamilton
Sheva
Tarey Wolf
Sheva
D11
Sheva
Phill Midwinter
Hello,
thank you. Now it works.
Best regards,
Thorsten
marcy
Hello,
here my code in page:
<
Page x:Class="Page2" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="bilder" Style="{StaticResource DefaultLayout}" ShowsNavigationUI="False">
</
Page>Code Behind:
Partial
Public Class Page2 Inherits System.Windows.Controls.Page Dim LayoutData As DefaultLayoutData Public Sub New()InitializeComponent()
Dim o As ObjectDataProvidero =
Me.Style.Resources("LayoutData")LayoutData = o.Data
LayoutData.CurrentDescription =
"current description"LayoutData.CurrentItem =
"currentitem"LayoutData.PageSubTitle =
"subtitle"Dim obj As Object = Template.FindName("backGrid", Me)
If obj Is Nothing Then
Console.WriteLine(
"null") ElseConsole.WriteLine(obj.ToString)
End If End Sub End ClassThats all. I can see all controls where i defined in the Style "DefaultLayout".
I hope you mean this...my english...
Thorsten
djchapin
Hello,
i`ve tried this:
Dim
obj As Object = Template.FindName("backGrid", Me) If obj Is Nothing ThenConsole.WriteLine(
"null") ElseConsole.WriteLine(obj.ToString)
End IfThats don't work. The Function returns nothing.