首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 媒体动画 > CAD教程 >

WPF DataGrid 模版嵌套DataGrid有关问题

2013-01-02 
WPF DataGrid 模版嵌套DataGrid问题本帖最后由 PangXiangShan 于 2012-12-03 16:01:55 编辑DataGrid 模版

WPF DataGrid 模版嵌套DataGrid问题
本帖最后由 PangXiangShan 于 2012-12-03 16:01:55 编辑 DataGrid 模版列嵌套一个DataGrid 怎么获得模版里的 DataGrid 对象
还有就是应该在那个事件里写
我在模版里嵌套的DataGrid里面也添加了模版列 怎么获得模版列里面的控件对象
[解决办法]
下面是我的测试
c#  


public class Stu : INotifyPropertyChanged
    {
        private string _name;
        public string Name {
            get { return _name; }
            set { _name = value;
            OnPropertyChanged("Name");
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;
        public void OnPropertyChanged(string info)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(info));
            }
        }

        private List<Stu> _ename;
        public List<Stu> EListName
        {
            get { return _ename; }
            set {
                _ename = value;
                OnPropertyChanged("EListName");
            }
        }

    }

xaml

    <sdk:DataGrid x:Name="dg" HorizontalAlignment="Left" Height="164" Margin="68,56,0,0"
            CellEditEnding="dg_CellEditEnding_1"    AutoGenerateColumns="False"      VerticalAlignment="Top" Width="187">
            <sdk:DataGrid.Columns>
                <sdk:DataGridTemplateColumn  Header="woca"   >
                    <sdk:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <sdk:DataGrid x:Name="cellData" ItemsSource="{Binding EListName}">


                                <sdk:DataGrid.Columns>
                                    <sdk:DataGridTemplateColumn>
                                        <sdk:DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBlock Text="{Binding Name}"></TextBlock>
                                            </DataTemplate>
                                        </sdk:DataGridTemplateColumn.CellTemplate>
                                    </sdk:DataGridTemplateColumn>
                                </sdk:DataGrid.Columns>
                            </sdk:DataGrid>
                            <!--<TextBlock Text="{Binding Name, Mode=TwoWay}"> </TextBlock>-->
                        </DataTemplate>
                    </sdk:DataGridTemplateColumn.CellTemplate>
                    <sdk:DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <TextBox Text="{Binding Name, Mode=TwoWay}"></TextBox>
                        </DataTemplate>


                    </sdk:DataGridTemplateColumn.CellEditingTemplate>
                </sdk:DataGridTemplateColumn>
            </sdk:DataGrid.Columns>
            
        </sdk:DataGrid>

热点排行