T
T
Tsiren Naimanov2015-02-10 13:06:23
C++ / C#
Tsiren Naimanov, 2015-02-10 13:06:23

Why is the variable marked in XAML x:Name ="man" not visible in the xaml.cs code itself?

<Page
    x:Class="Ideal.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Ideal"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Grid>
        <Grid.Background>
            <ImageBrush Stretch="Fill" ImageSource="Assets/879269ac-e4c9-41f5-b52b-2709b5cf4cd1_4.jpg"/>
        </Grid.Background>
        <Hub Header="Find your Ideal" x:Name="hub1" RenderTransformOrigin="0.209,0.461">
            <HubSection x:Name="MainHub">
                <DataTemplate >
                    <Grid>
                        <TextBlock x:Name="tbFirst" HorizontalAlignment="Left" 
        				Margin="70,400,0,0"
        				TextWrapping="Wrap" 
        				Text="Что такое идеал?
                               На протяжении всей истории человечества
                               Мы стремимся к идеалу
                               У каждого человека свой идеал в жизни" 
        				VerticalAlignment="Top" 
        				Height="230" 
        				Width="300" FontSize="24" TextAlignment="Center" />
                    </Grid>
                </DataTemplate>
            </HubSection>
            <HubSection x:Name="wom">
                <DataTemplate>
                    <ContentControl x:Name="cCw">
                    <Border BorderBrush="YellowGreen" BorderThickness="4" Height="600" >
                        <Image x:Name="womanI" HorizontalAlignment="Left" 
                               Height="600" Margin="0,0,0,0" VerticalAlignment="Top" 
                               Width="400" Source="Assets/irina_shayk_jessica_.jpg" Stretch="UniformToFill" />
                    </Border>
                    </ContentControl>
                </DataTemplate>
            </HubSection>
            <HubSection x:Name="man">
                <DataTemplate x:Name="d1">
                    <ContentControl x:Name="cCm">
                    <Border BorderBrush="YellowGreen" BorderThickness="4" Height="600">
                        <Image x:Name="manI"  HorizontalAlignment="Right"
        		                Height="600" Margin="0,0,0,0" VerticalAlignment="Top" 
        		                Width="400" Source="Assets/202045.jpg" Stretch="UniformToFill" />
                    </Border>
                    </ContentControl>
                </DataTemplate>
            </HubSection>
            <HubSection Width="900">
                <DataTemplate>
                    
                </DataTemplate>
            </HubSection>
        </Hub>
    </Grid>
</Page>

Why are Hubs visible? and what is not in them?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2015-02-11
@renoize

Your controls are in the DataTemplate, so they are not available in the codebehind. The easiest way to "reach out" to an element inside a DataTemplate is to add a Loaded event, for example, to the ContentControl.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question