关于WCF RIA Service 删除操作的问题?请教各位,先谢谢了
[解决办法]
<Grid x:Name="LayoutRoot" Background="White">
<Button Content="删除" Height="23" HorizontalAlignment="Left" Margin="12,208,0,0" Name="bt_del" VerticalAlignment="Top" Width="75" Click="bt_del_Click" />
<sdk:DataGrid AutoGenerateColumns="True" Height="190" HorizontalAlignment="Left" ItemsSource="{Binding ElementName=movieDomainDataSource, Path=Data}" Margin="12,12,0,0" Name="movieDataGrid" RowDetailsVisibilityMode="VisibleWhenSelected" VerticalAlignment="Top" Width="164"/>
</Grid>
namespace SLA20131012
{
public partial class MainPage : UserControl
{
private MovieDomainContext movieCtx = new MovieDomainContext();
public MainPage()
{
InitializeComponent();
LoadOperation<Movie> loadMovies = movieCtx.Load(movieCtx.GetMovieQuery());
loadMovies.Completed += loadMovies_Completed;
}
void loadMovies_Completed(object sender, EventArgs e)
{
LoadOperation<Movie> temp = (LoadOperation<Movie>)sender;
movieDataGrid.ItemsSource = temp.Entities;
}
private void bt_del_Click(object sender, RoutedEventArgs e)
{
Movie movie = movieDataGrid.SelectedItem as Movie;
this.movieCtx.Movies.Remove(movie);
this.movieCtx.SubmitChanges();
}
}
}