如何使用该datagrid的事件访问datagrid中的文本框?

问题描述:

我在数据网格中有一个使用xaml设计的文本框。我是否可以使用datagrid的事件访问先前在codefile中使用xaml设计的文本框。请帮帮我.....................

I have a textbox in a datagrid that is designed using xaml. Can I access the textbox which has been designed in xaml previously in codefile using the events of the datagrid. Please help me.....................

<br />
<Window x:Class="GridTextBox.Test"<br />
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"<br />
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" WindowState="Maximized"<br />
    Title="Test" Height="300" Width="300" Loaded="Window_Loaded"><br />
<Grid><br />
    <Grid.RowDefinitions><br />
        <RowDefinition Height="30"/><br />
        <RowDefinition Height="*"/><br />
        <RowDefinition Height="30"/><br />
    </Grid.RowDefinitions><br />
    <Grid.ColumnDefinitions><br />
        <ColumnDefinition Width=".25*"/><br />
<br />
        <ColumnDefinition Width=".25*"/><br />
        <ColumnDefinition Width=".25*"/><br />
        <ColumnDefinition Width=".25*"/><br />
    </Grid.ColumnDefinitions><br />
    <DataGrid Grid.Row="1" Grid.Column="1"  Name="datagrid1" SelectionChanged="datagrid1_SelectionChanged" LoadingRowDetails="DataGrid_LoadingRowDetails"  Height="auto" Width="auto"><br />
        <DataGrid.Columns><br />
            <DataGridTemplateColumn><br />
                <DataGridTemplateColumn.CellTemplate><br />
                    <DataTemplate><br />
                        <TextBox Name="txtEmpid" Text="hiiiiii"></TextBox><br />
                    </DataTemplate><br />
                </DataGridTemplateColumn.CellTemplate><br />
            </DataGridTemplateColumn><br />
        </DataGrid.Columns><br />
    </DataGrid><br />
</Grid><br />

请检查一下......

http://www.c-sharpcorner.com/UploadFile/8911c4/how-to-find- control-and-value-form-datagrid-in-wpf / [ ^ ]



这里有两个DataGridTemplateColumns并在一个datatemplate中访问另一个控件...
Please check this...
http://www.c-sharpcorner.com/UploadFile/8911c4/how-to-find-control-and-its-value-form-datagrid-in-wpf/[^]

Here there are two DataGridTemplateColumns and accessing a control within one datatemplate from another...