本文介绍了根据组合框的选择保存在数据库的不同表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我必须创建传递具有一对多关系的实体的通用视图模型.我将解释:我的窗口:
<Window x:Class="Invoice_Example_Brux.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:invoiceExampleBrux="clr-namespace:Invoice_Example_Brux"
Title="MainWindow" Height="350" Width="525">
<Window.DataContext>
<invoiceExampleBrux:MainWindowViewModel/>
</Window.DataContext>
<Grid>
<TextBox HorizontalAlignment="Left" Height="23" Margin="174,78,0,0" TextWrapping="Wrap" Text="{Binding MyModel.Name}" VerticalAlignment="Top" Width="120"/>
<Label Content="Id" HorizontalAlignment="Left" Margin="10,53,0,0" VerticalAlignment="Top"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="10,78,0,0" TextWrapping="Wrap" Text="{Binding MyModel.Id}" VerticalAlignment="Top" Width="120" IsReadOnly="True"/>
<Label Content="Number" HorizontalAlignment="Left" Margin="322,52,0,0" VerticalAlignment="Top"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="322,78,0,0" TextWrapping="Wrap" Text="{Binding MyModel.Number}" VerticalAlignment="Top" Width="120"/>
<Label Content="Name" HorizontalAlignment="Left" Margin="174,53,0,0" VerticalAlignment="Top"/>
<Button Content="Save" HorizontalAlignment="Left" Margin="211,288,0,0" VerticalAlignment="Top" Width="75" Command="{Binding SaveCommand}"/>
<ComboBox
SelectionChanged="Selector_OnSelectionChanged"
HorizontalAlignment="Left" Margin="180,38,0,0" VerticalAlignment="Top" Width="120"
DisplayMemberPath="Name"
ItemsSource="{Binding DocumentType,UpdateSourceTrigger=PropertyChanged}"/>
<Label Content="Type Document" HorizontalAlignment="Left" Margin="192,12,0,0" VerticalAlignment="Top"/>
</Grid>
myWindows codebheind:
myWindows codebheind:
推荐答案
这篇关于根据组合框的选择保存在数据库的不同表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!