翻譯|使用教程|編輯:龔雪|2020-09-10 10:23:16.173|閱讀 290 次
概述:本文將演示如何將WcfInstantFeedbackDataSource或WcfServerModeDataSource與DXGrid一起使用,以及如何通過特殊行為在應(yīng)用程序中實(shí)現(xiàn)CRUD操作(例如,添加、刪除、編輯)。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
下載DevExpress v20.1完整版 DevExpress v20.1漢化資源獲取
通過DevExpress WPF Controls,您能創(chuàng)建有著強(qiáng)大互動功能的XAML基礎(chǔ)應(yīng)用程序,這些應(yīng)用程序?qū)W⒂诋?dāng)代客戶的需求和構(gòu)建未來新一代支持觸摸的解決方案。
本文將演示如何將WcfInstantFeedbackDataSource或WcfServerModeDataSource與DXGrid一起使用,以及如何通過特殊行為在應(yīng)用程序中實(shí)現(xiàn)CRUD操作(例如,添加、刪除、編輯)。
該測試需要在您的計算機(jī)上安裝SQL Express服務(wù)。
我們?yōu)镚ridControl創(chuàng)建了WCFServerModeCRUDBehavior和WCFInstantModeCRUDBehavior附加操作,例如:
<dxg:GridControl> <i:Interaction.Behaviors> <crud:WCFServerModeCRUDBehavior ...> <crud:WCFServerModeCRUDBehavior.DataSource/> <dxsm:LinqServerModeDataSource .../> </crud:WCFServerModeCRUDBehavior.DataSource> </crud:WCFServerModeCRUDBehavior> </i:Interaction.Behaviors> </dxg:GridControl>
WCFServerModeCRUDBehavior和WCFInstantModeCRUDBehavior類包含NewRowForm和EditRowForm屬性,以提供"Add Row"和"Edit Row"操作。使用這些屬性,可以根據(jù)需要創(chuàng)建添加和編輯表單:
<DataTemplate x:Key="EditRecordTemplate"> <StackPanel Margin="8" MinWidth="200"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition/> <ColumnDefinition/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition/> <RowDefinition/> </Grid.RowDefinitions> <TextBlock Text="ID:" VerticalAlignment="Center" Grid.Row="0" Grid.Column="0" Margin="0,0,6,4" /> <dxe:TextEdit x:Name="txtID" Grid.Row="0" Grid.Column="1" EditValue="{Binding Path=Id, Mode=TwoWay}" Margin="0,0,0,4" /> <TextBlock Text="Name:" VerticalAlignment="Center" Grid.Row="1" Grid.Column="0" Margin="0,0,6,4" /> <dxe:TextEdit x:Name="txtCompany" Grid.Row="1" Grid.Column="1" EditValue="{Binding Path=Name, Mode=TwoWay}" Margin="0,0,0,4" /> </Grid> </StackPanel> </DataTemplate> <crud:WCFServerModeCRUDBehavior NewRowForm="{StaticResource ResourceKey=EditRecordTemplate}" EditRowForm="{StaticResource ResourceKey=EditRecordTemplate}"/>
此操作類需要您的數(shù)據(jù)模型中的以下信息:
<dxg:GridControl> <i:Interaction.Behaviors> <crud:WCFInstantModeCRUDBehavior EntityObjectType="{x:Type sr:Item}" DataSource="{Binding ElementName=wcfInstantSource}" DataServiceContext="{Binding DataSource.DataServiceContext, RelativeSource={RelativeSource Self}}"/> </i:Interaction.Behaviors> </dxg:GridControl>
helper.PropertiesList.Add("Id"); helper.PropertiesList.Add("Name");
請參閱和類以了解有關(guān)WcfInstantFeedbackDataSource和WcfServerModeDataSource的更多信息。
操作類的后代支持以下命令:NewRowCommand、RemoveRowCommand、EditRowCommand,您可以輕松地將交互控件與這些命令綁定在一起。 例如:
<crud:WCFServerModeCRUDBehavior x:Name="helper"/> <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center"> <Button Height="22" Width="60" Command="{Binding Path=NewRowCommand, ElementName=helper}">Add</Button> <Button Height="22" Width="60" Command="{Binding Path=RemoveRowCommand, ElementName=helper}" Margin="6,0,6,0">Remove</Button> <Button Height="22" Width="60" Command="{Binding Path=EditRowCommand, ElementName=helper}">Edit</Button> </StackPanel>
默認(rèn)情況下,WCFServerModeCRUDBehavior和WCFInstantModeCRUDBehavior解決方案支持以下最終用戶交互功能:
DevExpress技術(shù)交流群2:775869749 歡迎一起進(jìn)群討論
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自:慧都網(wǎng)