forum

Home / DeveloperSection / Forums / How can i get the element from xaml to C# through Resource dictionary?

How can i get the element from xaml to C# through Resource dictionary?

Anonymous User332716-Aug-2013
Hi Developers!

Just for an example i have the below code in template.xaml.

<Border x:Name="PART_ButtonNormal" Grid.Column="0">

    <Grid>

        <Grid.ColumnDefinitions>

            <ColumnDefinition Width="Auto" />

            <ColumnDefinition />

        </Grid.ColumnDefinitions>

        <Border Name="PART_ImageBorder" Grid.Column="0">

            <Grid>

                <Grid.RowDefinitions>

                    <RowDefinition Height="Auto"/>

                    <RowDefinition Height="Auto"/>

                </Grid.RowDefinitions>

                <Image Margin="2" Width="16"  Source="{Binding Path=SmallIcon, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"/>

                <Border Height="20" Grid.Row="1" Background="Red"/>

             </Grid>

         </Border>

         <TextBlock Grid.Column="1" x:Name="PART_Text" Text="{TemplateBinding Label}"

                                    Foreground="{TemplateBinding Foreground}"

                                    FontFamily="{TemplateBinding FontFamily}"

                                    FontSize="{TemplateBinding FontSize}"

                                    VerticalAlignment="{TemplateBinding VerticalAlignment}"                          

                                    HorizontalAlignment="{TemplateBinding HorizontalAlignment}"

                                    Margin="2,0,4,0"/>

    </Grid>

</Border> 

I read this xaml in Wrapper.cs class through Resource dictionary. Then how can i access the Image element from template.xaml in Wrapper.cs. 

Could you please any one give me the solution?.


Updated on 17-Aug-2013
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By