简体   繁体   English

WPF带有Datagrid复选框的多个ID

[英]WPF multiple ID's with Datagrid Checkboxes

I'm working on a school project right now where I wanted to challenge myself, so I thought myself how to work with WPF Applications but I ran into an issue which I can't figure out myself. 我现在正在一个学校项目上,我想挑战自己,所以我想到了如何使用WPF应用程序,但是遇到了一个我自己不知道的问题。 The issue I'm having is, that I can't select multiple ID's from the row where the checkboxes are checked. 我遇到的问题是,我无法从选中复选框的行中选择多个ID。

What should the program do with the IDs? 程序应如何处理ID?

  1. Select x ID's 选择x ID
  2. Open a new window foreach found ID 为找到的每个ID打开一个新窗口

Pictures showing the program: 图片显示程序:

Window 窗口

Designer Code 设计师代码

So if the user presses one of the buttons on the topleft after selecting at least one row with a checkbox the program should select the ID's from the column[0] "Kunden-Nr". 因此,如果用户在选中带有复选框的至少一行后按下左上角的按钮之一,则程序应从[0]“ Kunden-Nr”列中选择ID。 I can only manage to do it with a single row with a doubleclick event which selects the value from the first column of the selected row. 我只能通过具有doubleclick事件的单行来做到这一点,该事件会从所选行的第一列中选​​择值。

Datagrid Designer code for people that don't want to open the picture. 不想打开图片的人的Datagrid Designer代码。

<Grid Grid.Row="1" Grid.Column="1">
                    <DataGrid x:Name="dgvCustomerOverview" AutoGenerateColumns="False">
                        <DataGrid.Columns>
                            <DataGridTextColumn Binding="{Binding KD_NR}" Header="Kunden-Nr" Width="0.7*"/>
                            <DataGridTextColumn Binding="{Binding KD_Name}" Header="Name" Width="*"/>
                            <DataGridTemplateColumn Header="Geburtstag" Width="*">
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <TextBlock Style="{StaticResource dgvPadding}" Text="{Binding KD_Gebtag, StringFormat=\{0:dd.MM.yy\}}"/>
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                            <DataGridTextColumn Binding="{Binding KD_Plz}" Header="Postleitzahl" Width="0.75*"/>
                            <DataGridTextColumn Binding="{Binding KD_Ort}" Header="Ort" Width="*"/>
                            <DataGridTextColumn Binding="{Binding KD_Strasse}" Header="Straße" Width="*"/>
                            <DataGridTextColumn Binding="{Binding KD_HausNr}" Header="Haus-Nr" Width="0.55*"/>
                            <DataGridTextColumn Binding="{Binding KD_Email}" Header="E-Mail" Width="*"/>
                            <DataGridTextColumn Binding="{Binding KD_Privattel}" Header="Tel. Privat" Width="*"/>
                            <DataGridTextColumn Binding="{Binding KD_Mobiltel}" Header="Tel. Mobil" Width="*"/>
                            <DataGridCheckBoxColumn Header="Auswählen" Width="0.75*"/>
                        </DataGrid.Columns>
                    </DataGrid>
                </Grid>

在DataGrid中,您可以使用SelectedItem =“ {Binding MyProperty,UpdateSourceTrigger = PropertyChanged}”并获取选定的行

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM