码迷,mamicode.com
首页 > Web开发 > 详细

silverlight DataGrid 添加删除列/删除按钮

时间:2015-07-29 12:05:58      阅读:265      评论:0      收藏:0      [点我收藏+]

标签:

<sdk:DataGrid x:Name="DataGrid1" HorizontalAlignment="Center"  VerticalAlignment="Top"  Margin="0,41,0,0" AutoGenerateColumns="False"  IsReadOnly="True">
            <sdk:DataGrid.Columns>
                <sdk:DataGridTextColumn Header="id" Binding="{Binding ID}"/>
                <sdk:DataGridTextColumn Header="用户名" Binding="{Binding UserName}"/>
                <sdk:DataGridTextColumn Header="BirtherDate" Binding="{Binding BirtherDate,StringFormat=yyyy-MM-dd HH:mm:ss}"/>
                <sdk:DataGridTextColumn Header="Height" Binding="{Binding Height}"/>
                <sdk:DataGridTextColumn Header="Sex" Binding="{Binding Sex}"/>
                <sdk:DataGridTemplateColumn Width="60"  Header="删除">
                    <sdk:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Button Content="删除"  Click="Button_Click_del" Width="55" />
                        </DataTemplate>
                    </sdk:DataGridTemplateColumn.CellTemplate>                        
                </sdk:DataGridTemplateColumn>
            </sdk:DataGrid.Columns>
        </sdk:DataGrid>
1 private void Button_Click_del(object sender, RoutedEventArgs e)
2         {
3             Button b = sender as Button;
4             Person P = (Person)b.DataContext;//获取当前数据
5             if (P!=null)
6             {
7                 client.DeleteAsync(P);//删除
8             }
9         }

技术分享

silverlight DataGrid 添加删除列/删除按钮

标签:

原文地址:http://www.cnblogs.com/zhulinfeng/p/4685392.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!