Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I had a xaml in mainpage and want to access it's elements like x:Name="D1P1" in a c# class but can't use it and get an error the name "D1P1" does not exist in the current context any idea how to access the hub elements in c# class I use FindName but it did't work

XML
<HubSection Width="950" x:Name="DayOneTimeHubSection" Margin="20,0,0,0">
                <DataTemplate>
                    <Grid>
                        <StackPanel Orientation="Vertical">
                            <StackPanel Orientation="Horizontal" Height="180" Margin="0,0,0,-15">
                                <StackPanel Width="280" Height="160" Background="#FF253842" Margin="05,0,0,0">
                                    <TextBlock x:Name="D1P1"  HorizontalAlignment="Center" LineHeight="80" TextWrapping="Wrap"  FontSize="64" TextAlignment="Center" Foreground="#FFB0B1B2" FontFamily="Arial Narrow" Margin="0,10,0,0" />
                                    <TextBlock x:Name="D1NP1" HorizontalAlignment="Center" VerticalAlignment="Bottom" LineHeight="64" TextWrapping="Wrap"  FontSize="64" TextAlignment="Center" Foreground="White" FontFamily="DengXian" Margin="30,0" />
                                </StackPanel>

                       </StackPanel>

                </StackPanel>

</Grid>

</DataTemplate>

</hubsection>
Posted
Updated 4-Mar-16 20:51pm
v2

1 solution

You cannot access controls inside a hub section as because they were inside a data template. if you use MVVM you can bind the data.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900