data binding - Accessing underlying ViewModel properties within a WPF DataGrid GroupItem DataTemplate -


I have a grouped WPF DataGrid (Standard Microsoft is one) to represent some data on the UI for our users.

To show the sum in the grouped areas, we are overriding the group item datappler, as in XAML:

  & gt; Style Target Type = "{x: Type GroupItem}" & gt; & Lt; Setter Estates = "Template" & gt; & Lt; Setter.Value & gt; & Lt; ControlTemplate TargetType = "{x: Type GroupItem}" & gt; & Lt; Border Borderbrush = "DarkGrey" BorderTrains = "1" padding = "12,0" & gt; & Lt; Expander VerticalContentAlignment = "Center" IsExpanded = "{Binding., Converters = {Converters: Extended Group Converter}}" Extended Direction = "Top" & gt; & Lt; Expander.Header & gt; & Lt; Canvas & gt; ** & lt; TextBlock text = "{binding} /> **  gt; & lt; /Expander.Header & amp; mj; ItemPresenter / & gt; & lt; / Expander & gt; & lt; / border & Gt; & lt; / ControlTemplate & gt; & lt; / Setter.value & gt; & lt; / centrum & gt; & lt; / style & gt;   

On the runtime, the current In, the textbox is connected to text datacontext, which is collections group, which is understandable that the grid is bound to collection Viv to wrap our data source.

However, the collection view group is very Is limited and we have U does not provide access to modal, where we are collecting properties, where the position of groups (we coordinate with the columns we are collecting when we first take the grid), and need to bind them, For example, we can show a group directly in the top / bottom column.

In short, we are just trying to use more than the CollectionView object from within a DataTemplate, which That The group targets the item. This is how to do any input (or if there is a better way to get a summary). Total templates per Yoga group per column)

Edit: So far, one solution is for a "Father ViewModel" property on our items, although this model bloats, I There was one more direct way to do this.

The collection view group gives you access to all the objects contained in this group. If you want to use other information from within your template, you can try binding with RelativSource

Edit:.

So if you have a collection of ItemVM, and this is the ItemVM.GroupProperty on CollectionViewGroup at the top of one. So with your you can use your 1 ItemVM within a group

  binding = {path = item [0] .AnyPropertyOnItemVM}   

I think Use a converter that you have to do if you want to calculate or do anything with the group item

Comments