如何在DatagridTemplate中更改文本框值

时间:2019-03-23 20:42:09

标签: wpf datagrid

我需要使用datagrid中的updown按钮更改文本框并获取当前值

<DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <Grid >
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="20"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*"/>
                                <RowDefinition Height="1"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>
                            <TextBox Grid.Row="1"  Grid.Column="0" Grid.ColumnSpan="2" x:Name="txtNum"   
                             TextChanged="TxtNum_TextChanged" VerticalAlignment="Center"  />
                            <Button x:Name="cmdUp" Grid.Column="2" Grid.Row="2" Click="cmdUp_Click"/>
                            <Button x:Name="cmdDn" Grid.Column="2" Grid.Row="0"/ ></Button>
                        </Grid>
                    </DataTemplate>
                </DataGridTemplateColumn.CellTemplate>

0 个答案:

没有答案