反射无法在DataGridCellInfo中获取运行时属性值 [英] Reflection not working to get run time Property Values in DataGridCellInfo

查看:101
本文介绍了反射无法在DataGridCellInfo中获取运行时属性值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

反射无法在DataGridCellInfo中获取运行时属性值。


Wpf - Datagrid -   SelectedCellsChanged - 更改事件

 private void Dgv_OnSelectedCellsChanged(object sender,SelectedCellsChangedEventArgs e)
{
var pp = e.AddedCells [0];
PropertyInfo rowDataItemProperty = pp.GetType()。GetProperty(" ItemInfo",BindingFlags.Instance | BindingFlags.NonPublic);
}


< DataGrid Name =" dgv" RowHeaderWidth = QUOT; 50" SelectedCellsChanged = QUOT; Dgv_OnSelectedCellsChanged" SelectionUnit = QUOT; CellOrRowHeader"的AutoGenerateColumns = QUOT假QUOT; ItemsSource =" {Binding ViewModelCollection}" IsSynchronizedWithCurrentItem = QUOT;真" CanUserAddRows = QUOT假QUOT; MinColumnWidth = QUOT; 80 QUOT; columnWidth时= QUOT; 80 QUOT; CanUserResizeRows = QUOT假QUOT; CanUserResizeColumns = QUOT假QUOT;余量= QUOT; 0,55,-0.287,0.168"> 
< DataGrid.Columns>
< DataGridTextColumn Header =" Dosage" Binding =" {Binding Path = Dosage}" />
< DataGridTextColumn Header =" Drug" Binding ="{Binding Path = Drug}" />
< DataGridTextColumn Header =" Patient" Binding =" {Binding Path = Patient}">
< DataGridTextColumn Header =" Date" Binding =" {Binding Path = Date}">
< /DataGrid.Columns>
< / DataGrid>

我的要求很简单。




我只需要索引,但在进入ItemInfo属性后我看不到索引.....

 pp.ItemInfo索引:2  Item:{WpfApp22.Model} System.Windows.Controls.ItemsControl.ItemInfo 


在运行时索引变化.....


我只需要索引编号。




解决方案

ItemInfo不属于  dataGridCellInfo。

Reflection not working to get run time Property Values in DataGridCellInfo.

Wpf - Datagrid - SelectedCellsChanged - Changed Event

 private void Dgv_OnSelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
        {
            var pp = e.AddedCells[0];
            PropertyInfo rowDataItemProperty = pp.GetType().GetProperty("ItemInfo", BindingFlags.Instance | BindingFlags.NonPublic);
        }

<DataGrid Name="dgv" RowHeaderWidth="50" SelectedCellsChanged="Dgv_OnSelectedCellsChanged"  SelectionUnit="CellOrRowHeader"  AutoGenerateColumns="False" ItemsSource="{Binding ViewModelCollection}" IsSynchronizedWithCurrentItem="True" CanUserAddRows="False" MinColumnWidth="80" ColumnWidth="80" CanUserResizeRows="False" CanUserResizeColumns="False" Margin="0,55,-0.287,0.168">
            <DataGrid.Columns>
                <DataGridTextColumn Header="Dosage" Binding="{Binding Path=Dosage}" />
                <DataGridTextColumn Header="Drug" Binding="{Binding Path=Drug}" />
                <DataGridTextColumn Header="Patient" Binding="{Binding Path=Patient}"/>
                <DataGridTextColumn Header="Date" Binding="{Binding Path=Date}"/>
            </DataGrid.Columns>
        </DataGrid>

My Requirement is Simple.

I Just Need the Index, But after getting into ItemInfo Property I dont see Index.....

pp.ItemInfo	Index: 2  Item: {WpfApp22.Model}	System.Windows.Controls.ItemsControl.ItemInfo

At runtime index changes.....

I need Just Index Number .

解决方案

ItemInfo is not a property of dataGridCellInfo.


这篇关于反射无法在DataGridCellInfo中获取运行时属性值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆