当前位置导航:炫浪网>>网络学院>>编程开发>>Visual C#教程

C#代码实现DataTemplate

不得不说DataTemplate是WPF中的一项重要技术组成,可以方便让我们实现各种各样的UI样式,大大丰富了应用程序的界面设计。

通常我们都会在XAML文件中定义出具体的DataTemplate, 我举一个ListView的例子:

Code
<ListView IsSynchronizedWithCurrentItem="True" Background="#FFFFFFFF" Foreground="White" ItemsSource="{Binding}" Style="{DynamicResource SuperListViewStyle}" ItemContainerStyleSelector="{StaticResource listViewItemStyleSelector}" x:Name="lvExecutionTable" >
                        <ListView.View>
                            <GridView>
                                <GridViewColumn>
                                    <GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <CheckBox HorizontalAlignment="Center" IsChecked="{Binding Path=IsSelected}"/>
                                        </DataTemplate>
                                    </GridViewColumn.CellTemplate>
                                    <GridViewColumnHeader Content="选择" Tag="IsSelected"/>
                                </GridViewColumn>
                                <GridViewColumn>
                                    <GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <TextBlock 

相关内容
赞助商链接