c# - How do I access the controls in a WPF DataGrid -


itemprop = "text">

Good old (well!) Datagram row in WinForms days is used as real control and you Can access DataItem

All its flip and datagrid in WPF. ITEMS is the only source data.

I am probably doing this wrongly round like as a bit of WPF, I can repeat through lines of my gridview to get values ​​from some labels, text boxes, etc. Am I

Yes, you are doing it wrongly, what should you do through the objects in your data source Want to walk - this is where all the values ​​are after all.

It is possible to repeat through WPF objects, but it is not trivial and if you try, then there is a big problem that you will run in.

You can use the VisualTreeHelper class to search for the visual tree and find the descendants of DataGrid . If you play this for a long time, in the end you can find out how to find the particular controls you are looking for. But DataGrid (in fact, virtualizing stackpayel in your control template) virtualizes your view children. If an item is not yet displayed on screen, its WPF object Not created yet, and you will not find them in the visual tree. You can not be able to find what you are looking for, not because you do not have any way to find it, but because it does not exist.

If you are using value converters and formatting in your binding (which is the only reason you can think about that you want to see WPF objects and not see the underlying data items ), I'm afraid, the answer is: Do not do this by value conversion and formatting in your data source, and the results can be directly formed.

It is definitely possible to use WPF without using the MVVM pattern but it is a brick wall that you can run in if you do not.


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -