Hello all
I want to have a DataRow that has 2 rows embedded,
I thought I'll use a UserControl that has 2 Dependency Properties, one for each row
(the properties are of type <object> in order to be able to add any type of content to it)
and set this UserControl as the ControlTemplate of the DataRow.
I have chosen a UserControl because I want to reuse this user control for all of the grids in my application
while keeping the ability to change the Content of those rows dynamically
I have done that, but now I can't seem to get the binding to work!!!!!!
Here is a simple code sample (I've excluded the attributes and other stuff that are irrelevant to this case)
<xcdg:DataGridCollectionViewSource>
<xcdg:DataGridCollectionViewSource.ItemsProperties>
<xcdg:DataGridItemProperty Name="FirstName" DataType="{X:Type s:String}"/>
<xcdg:DataGridItemProperty Name="LastName" DataType="{X:Type s:String}"/>
</xcdg:DataGridCollectionViewSource.ItemsProperties>
</xcdg:DataGridCollectionViewSource>
The Grid is set to have this DataGridCollectionViewSource as its ItemsSource
<ControlTemplate x:Key="MyControlTemplate" TargetType="{x:Type xdcg:DataRow}" >
<local:MyUserControl>
<local:MyUserControl.FirstRow>
<Grid>
<!-- some grid definitions -->
<xcdg:DataCell FieldName = "FirstName" ..../>
</Grid>
</local:MyUserControl.FirstRow>
<local:MyUserControl.SecondRow>
<Grid>
<!-- some grid definitions -->
<xcdg:DataCell FieldName = "LastName" ..../>
</Grid>
<local:MyUserControl.SecondRow>
</local:MyUserControl>
</ControlTemplate>
<Style Tartget="{x:Type xcdg:DataRow}">
<Setter Property="Template" Value="{StaticResource MyControlTemplate}"
</Style>
In my application, I see that the style is applied to the DataRow but the data behind it is not showing.
Am I missing something??
Keep in mind that the important issue here is that I need to keep is as generic as possible in
order to have maximum reusability.
I was able to make it work without the UserControl but I end up having the grid's configuration
hard coded in my xaml code.
Your help is appreciated