Silverlight 2 - Simple Editing of Web Service Data in a DataGrid
2008-10-24 11:46:57 来源:WEB开发网At the point where the "Submit Changes..." button is pressed I just gather up which entries have been inserted, updated, deleted as arrays and send them back over to the web service.
So...all in all, there's no rocket-science here at all. The XAML for my UI ends up looking like this;
<UserControl x:Class="SilverlightApplication14.Page"
xmlns="http://schemas.microsoft.com/client/2007"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
Width="400" Height="300">
<Grid x:Name="LayoutRoot" Background="White">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition
Height="48" />
<RowDefinition
Height="48" />
</Grid.RowDefinitions>
<Grid
x:Name="gridLoading"
Opacity="0.5"
Visibility="Collapsed">
<Rectangle
Fill="Silver"
RadiusX="10"
RadiusY="10"/>
<TextBlock
FontSize="24"
Text="Loading Grid..."
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Grid>
<d:DataGrid
x:Name="theGrid"
Margin="10">
<d:DataGrid.Columns>
<d:DataGridTextBoxColumn
Header="Id"
DisplayMemberBinding="{Binding Id}"
IsReadOnly="True"/>
<d:DataGridTextBoxColumn
Header="First Name"
DisplayMemberBinding="{Binding FirstName}" />
<d:DataGridTextBoxColumn
Header="Last Name"
DisplayMemberBinding="{Binding LastName}" />
<d:DataGridTextBoxColumn
Header="Age"
DisplayMemberBinding="{Binding Age}" />
</d:DataGrid.Columns>
</d:DataGrid>
<Button
Click="OnLoad"
Grid.Row="1"
Content="Load Data from Service"
Margin="10" />
<Button
Click="OnSave"
Grid.Row="2"
Content="Submit Changes to Service"
Margin="10"/>
</Grid>
</UserControl>
and the code behind the UI ends up looking like this ( pretty rough and ready stuff this );
Tags:Silverlight Simple Editing
编辑录入:爽爽 [复制链接] [打 印]- ››silverlight全屏显示图片
- ››Silverlight MVVM 模式(一) 切近实战
- ››Silverlight for Windows Phone 7开发系列(1):...
- ››Silverlight for Windows Phone 7开发系列(2):...
- ››Silverlight for Windows Phone 7开发系列(3):...
- ››Silverlight for Windows Phone 7开发系列(4):...
- ››Silverlight for Symbian
- ››Silverlight3系列(四)数据绑定 Data Binding 1
- ››Simple Cloud API:编写可移植的、可互操作的云应...
- ››silverlight2 游戏 1 你能坚持多少秒
- ››Silverlight开发实践--PicZoomShow
- ››Silverlight自定义控件开发 - 令人懊恼的OnApplyT...
更多精彩
赞助商链接