In Josh Smith's article,"WPF Apps With The Model-View-ViewModel Design Pattern"
In the code from AllCustomersView.xaml:
<DataTrigger Binding="{Binding Path=Name}" Value="True">
<Setter TargetName="txt" Property="Text" Value="Company" />
</DataTrigger>
I couldn't find out where the property--Name is. I thought it was in the CustomerViewModel.cs. But indeed it wasn't. How could I know the path of Name?
It comes from the CollectionViewSource:
<CollectionViewSource
x:Key="CustomerGroups"
Source="{Binding Path=AllCustomers}">
<CollectionViewSource.GroupDescriptions>
<PropertyGroupDescription PropertyName="IsCompany" />
</CollectionViewSource.GroupDescriptions>
<CollectionViewSource.SortDescriptions>
<scm:SortDescription PropertyName="IsCompany" Direction="Descending" />
<scm:SortDescription PropertyName="DisplayName" Direction="Ascending" />
</CollectionViewSource.SortDescriptions>
</CollectionViewSource>
When you use a CVS, it takes your data (in this case, a collection of CustomerViewModel instances), and splits them into groups (in this case, based on the property IsCompany).
Each group is placed in a CollectionViewGroup. A collection of these groups is then bound to the control that will be showing the groups. So the Name property is actually found on the CollectionViewGroup, and is the value of IsCompany (that's the PropertyGroupDescription), or the string value of a boolean.
If you change the binding to something invalid
<DataTrigger Binding="{Binding Path=Derp}" Value="True">
<Setter TargetName="txt" Property="Text" Value="Companies" />
</DataTrigger>
you'll see it stop working, and the following message show up in your output window:
System.Windows.Data Error: 39 : BindingExpression path error: 'Derp' property not found on 'object' ''CollectionViewGroupInternal' (HashCode=41413147)'. BindingExpression:Path=Derp; DataItem='CollectionViewGroupInternal' (HashCode=41413147); target element is 'ContentPresenter' (Name=''); target property is 'NoTarget' (type 'Object')
CollectionViewGroupInternal is the internal implementation of CollectionViewGroup that the CollectionViewSource uses to group your collection on the property IsCompany