-1
我有6個窗口,在他們每個人中我有一個gridview來顯示實體列表,並在gridview下我有三個按鈕(添加,編輯,刪除)。當用戶點擊刪除按鈕時,我想要一個彈出窗口打開並顯示此操作的結果(成功或錯誤)。 在所有窗口中執行此操作。 我的問題是,這是向用戶顯示彈出消息的最佳方式(根據我的代碼)? 我相信有一個更好的方法來做到這一點。如何在wpf應用程序中使用彈出窗口?
<DockPanel>
<Popup Name="SuccessPopup" StaysOpen="False" PlacementTarget="{Binding ElementName=menu}" Placement="Relative" Width="{Binding ActualWidth, ElementName=grdCustomers}" PopupAnimation="Fade" AllowsTransparency="True">
<Border BorderBrush="#0D8E16" BorderThickness="2.5" Background="#DFF3D6">
<TextBlock Margin="10" FontSize="12" FontFamily="Tahoma" Text="مشتری مورد نظر با موفقیت حذف شد." TextAlignment="Center" />
</Border>
</Popup>
<Popup Name="ErrorPopup" StaysOpen="False" PlacementTarget="{Binding ElementName=menu}" Placement="Relative" Width="{Binding ActualWidth, ElementName=grdCustomers}" PopupAnimation="Fade" AllowsTransparency="True">
<Border BorderBrush="#B30000" BorderThickness="2.5" Background="#FFDBDB">
<TextBlock Margin="10" FontSize="12" FontFamily="Tahoma" Text="متاسفانه مشکلی در حین حذف مشتری مورد نظر به وجود آمد." TextAlignment="Center" />
</Border>
</Popup>
<telerik:RadMenu Name="menu" ItemClick="menu_ItemClick" DockPanel.Dock="Top" TabIndex="0">
<telerik:RadMenuItem Header="{x:Static sr:ControlResource.File}">
<telerik:RadMenuItem Header="{x:Static sr:ControlResource.Export}">
<telerik:RadMenuItem Header="{x:Static sr:ControlResource.HtmlExport}" Name="mnuHtmlExport" />
<telerik:RadMenuItem Header="{x:Static sr:ControlResource.ExcelExport}" Name="mnuExcelExport" />
<telerik:RadMenuItem Header="{x:Static sr:ControlResource.WordExport}" Name="mnuWordExport" />
<telerik:RadMenuItem Header="{x:Static sr:ControlResource.CsvExport}" Name="mnuCsvExport" />
</telerik:RadMenuItem>
</telerik:RadMenuItem>
</telerik:RadMenu>
<Border Background="#FFF4F5F3" BorderBrush="#FF9E9A9A" DockPanel.Dock="Bottom" BorderThickness="1" Grid.Row="4" Margin="0">
<Grid DataContext="{Binding ElementName=grdCustomers, Path=SelectedItem}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="1*" />
</Grid.RowDefinitions>
<Label Name="lblName" Content="{x:Static sr:CustomerResource.Name}" Foreground="#FF3E3E3E" Grid.Column="1" />
<Label Name="lblTel" Content="{x:Static sr:CustomerResource.Tel}" Foreground="#FF3E3E3E" Grid.Column="1" Grid.Row="1" />
<Label Name="lblMobile" Content="{x:Static sr:CustomerResource.Mobile}" Foreground="#FF3E3E3E" Grid.Column="1" Grid.Row="2" />
<Label Name="lblAddress" Content="{x:Static sr:CustomerResource.Address}" Foreground="#FF3E3E3E" Grid.Column="1" Grid.Row="3" />
<telerik:RadMaskedTextBox Name="txtName" Value="{Binding Path=Name}" Grid.Row="0" HorizontalAlignment="Right" IsReadOnly="True" Margin="0,6,6,6" Width="200" TabIndex="4" />
<telerik:RadMaskedTextBox Name="txtTel" Value="{Binding Path=Tel}" Grid.Row="1" HorizontalAlignment="Right" IsReadOnly="True" Margin="0,6,6,6" Width="100" TabIndex="5" />
<telerik:RadMaskedTextBox Name="txtMobile" Value="{Binding Path=Mobile}" Grid.Row="2" HorizontalAlignment="Right" IsReadOnly="True" Margin="0,6,6,6" Width="100" TabIndex="6" />
<telerik:RadMaskedTextBox Name="txtAddress" Value="{Binding Path=Address}" Grid.Row="3" HorizontalAlignment="Right" IsReadOnly="True" Margin="0,6,6,6" Width="350" TabIndex="7" />
<Border Style="{StaticResource ButtonsBorder}" Grid.Row="4" Grid.ColumnSpan="2">
<StackPanel Orientation="Horizontal">
<Button Name="btnAddNewCustomer" Content="{x:Static sr:ControlResource.AddNewCustomer}" TabIndex="8" Width="120" Height="23" Margin="8,8,6,8" Click="btnAddNewCustomer_Click" />
<Button Name="btnEdit" IsEnabled="{Binding ElementName=grdCustomers, Path=HasItems}" Content="{x:Static sr:ControlResource.Edit}" TabIndex="9" Width="100" Height="23" Margin="0,8,6,8" Click="btnEdit_Click" />
<Button Name="btnDelete" IsEnabled="{Binding ElementName=grdCustomers, Path=HasItems}" Content="{x:Static sr:ControlResource.Delete}" TabIndex="10" Width="100" Height="23" Margin="0,8,6,8" Click="btnDelete_Click" />
</StackPanel>
</Border>
</Grid>
</Border>
<telerik:RadDataPager Name="dataPager" Grid.Row="3" PageSize="20" DockPanel.Dock="Bottom" TabIndex="2" />
<telerik:RadGridView Grid.Row="1" ItemsSource="{Binding PagedSource, ElementName=dataPager}" Name="grdCustomers" TabIndex="1" >
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn Header="{x:Static sr:CustomerResource.ID}" DataMemberBinding="{Binding ID}" MinWidth="50" MaxWidth="100" Background="#FFF8DD" />
<telerik:GridViewDataColumn Header="{x:Static sr:CustomerResource.Name}" DataMemberBinding="{Binding Name}" MinWidth="200" />
<telerik:GridViewDataColumn Header="{x:Static sr:CustomerResource.Tel}" DataMemberBinding="{Binding Tel}" MinWidth="150" />
<telerik:GridViewDataColumn Header="{x:Static sr:CustomerResource.Mobile}" DataMemberBinding="{Binding Mobile}" MinWidth="150" Width="*" />
</telerik:RadGridView.Columns>
</telerik:RadGridView>
</DockPanel>
這是有點不清楚,你真的想要做什麼。你只是想要某種地位出現在某個地方嗎?例如,您可以使用StatusBar。你想讓用戶確認結果嗎?你可以使用模態窗口,甚至是一個MessageBox。無限的可能性,像這樣一個開放的問題。 –