熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

C#代碼實現DataTemplate

2013-11-13 12:14:15  來源: .NET編程 

  不得不說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 >
                        <ListViewView>
                            <GridView>
                                <GridViewColumn>
                                    <GridViewColumnCellTemplate>
                                        <DataTemplate>
                                            <CheckBox HorizontalAlignment=Center IsChecked={Binding Path=IsSelected}/>
                                        </DataTemplate>
                                    </GridViewColumnCellTemplate>
                                    <GridViewColumnHeader Content=選擇 Tag=IsSelected/>
                                </GridViewColumn>
                                <GridViewColumn>
                                    <GridViewColumnCellTemplate>
                                        <DataTemplate>
                                            <TextBlock 
From:http://tw.wingwit.com/Article/program/net/201311/15468.html
    推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.