Click here to Skip to main content
15,900,907 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is my generic.xaml,i want to find the button control using c#.

HTML
<ResourceDictionary
    x:Class="ListViewCustomControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:WpfCustomControlLibrary2">
    <Style TargetType="{x:Type local:ListViewCustomControl}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:ListViewCustomControl}">
                    <Border  removed="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                        <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">                           
                            <StackPanel>
                                <ListView x:Name="ListView1" ItemsSource="{Binding}" Width="400" Foreground="Black"  
                                 HorizontalAlignment="Stretch" VerticalAlignment="Stretch" HorizontalContentAlignment="Center">                                   
                                    <ListView.View>                                       
                                        <GridView x:Name="GridView1">
                                            <GridViewColumn Width="390">                                                 
                                                <GridViewColumn.CellTemplate>                                                        
                                                    <DataTemplate>
                                                        <!--<Border Name="Border1"  BorderBrush="Black" Height="100">-->
                                                            <!--<Border.Background>
                                                                <ImageBrush  ImageSource="..\Images\BackColor.png"/>                                                                
                                                            </Border.Background>                                                          
                                                            <Border.BorderThickness>                                                                
                                                                <Thickness Bottom=".5"/>                                                                
                                                            </Border.BorderThickness>-->
                                                            <!--<WrapPanel>-->
                                                                <WrapPanel x:Name="WrapPanelLast"  Width="500" Height="100">
                                                                    <TextBlock Text="{Binding sdStartTime}" VerticalAlignment="Top"  Foreground="#F8A200"  Height="30" Width="80"/>
                                                                    <Rectangle Stroke="Red" Height="100"  StrokeThickness=".5"/>
                                                                    <Rectangle Margin="2,0,0,0" Stroke="Red" Height="100"  StrokeThickness=".5"/>
                                                                    <TextBlock FontWeight="Bold" Foreground="#626262"  Margin="10,0,0,0" VerticalAlignment="Top"   Height="30" Width="100"
                                                               Text="{Binding vcSubject}"/>
                                                                    <TextBlock Foreground="LightGray" FontWeight="Light" VerticalAlignment="Top" FontStyle="Oblique"
                                                                   FontFamily="Arial Rounded MT"  Height="30" Width="100"
                                                               Text="{Binding vcLocation}"/>
                                                                    <TextBlock Text="{Binding sdStartTime}" Margin="-350,20,0,0" VerticalAlignment="Top" Foreground="#F8A200"  Height="30" Width="50"/>
                                                                    <TextBlock Margin="-150,20,0,0" Text="-"/>
                                                                    <TextBlock Text="{Binding sdEndTime}" Margin="-250,20,0,0" VerticalAlignment="Top" Foreground="#F8A200"  Height="30" Width="50"/>
                                                                    <Button Content="{Binding vcGoogleMapsLocation}" x:Name="BttnMap" Margin="-310,25,0,0" 
                                                                              HorizontalContentAlignment="Right" Height="25"  Width="100">
                                                                        <Button.Background>
                                                                            <ImageBrush AlignmentX="Left" AlignmentY="Center"  ImageSource="Images\map.png">
                                                                            </ImageBrush>
                                                                        </Button.Background>
                                                                    </Button>
                                                                    <Button Content="{Binding vcConferenceCallNumber}" Margin="-100,25,0,0" HorizontalContentAlignment="Right" Height="25"  Width="100">
                                                                        <Button.Background>
                                                                            <ImageBrush AlignmentX="Left" AlignmentY="Center"   ImageSource="Images\button2.png">
                                                                            </ImageBrush>
                                                                        </Button.Background>
                                                                    </Button>
                                                                </WrapPanel>
                                                            <!--</WrapPanel>-->
                                                        <!--</Border>-->
                                                    </DataTemplate>
                                                </GridViewColumn.CellTemplate>
                                            </GridViewColumn>
                                        </GridView>
                                    </ListView.View>
                                </ListView>
                            </StackPanel>
                        </ScrollViewer>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
Posted

1 solution

You need to read this XAML file using XAML reader and then require to cast button
 
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