如何在c#中找到generic.xaml中的控件? [英] How to find a control inside generic.xaml in c#?

查看:234
本文介绍了如何在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


这篇关于如何在c#中找到generic.xaml中的控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆