如何在c#中找到generic.xaml中的控件?

如何在c#中找到generic.xaml中的控件?

问题描述:

这是我的generic.xaml,我想找到使用c#的按钮控件。



This is my generic.xaml,i want to find the button control using c#.

<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>

You need to read this XAML file using XAML reader and then require to cast button
You need to read this XAML file using XAML reader and then require to cast button