I have a GridView which lists all my Products. The first column is a "GridViewToggleRowDetailsColumn" which expands a Details-View when clicked.
I use CaliburnMicro to load the Details-View like so:
<telerik:RadGridView ItemsSource="{Binding Products.View}"
SelectedItem="{Binding SelectedProduct,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
AutoGenerateColumns="False"
EnableRowVirtualization="False"
ShowGroupPanel="False"
RowDetailsVisibilityMode="Collapsed"
RowIndicatorVisibility="Collapsed"
cal:Message.Attach="[Event RowDetailsVisibilityChanged] =
[Action OnRowDetailsVisibilityChanged($eventArgs)]">
<telerik:RadGridView.RowDetailsTemplate>
<DataTemplate>
<ContentControl cal:View.Model="{Binding DataContext.ProductDetailsViewModel, RelativeSource={RelativeSource FindAncestor, AncestorType=telerik:RadGridView}}" />
</DataTemplate>
</telerik:RadGridView.RowDetailsTemplate>
<telerik:GridViewToggleRowDetailsColumn />
...Columndefinitions...
</telerik:RadGridView>
I can open and close the details as long as I stay on the same product. The problem occurs if I open the details while another details is already visible. Then the details of the first disappears and never comes back. See the screenshot:
The grey box is a placeholder for the details. I opened the details of the first 8 items one after another, but only the last one is showing. My guess is that Caliburn Micro can not locate the View anymore, but I have no idea why? Because I only have one ProductDetailsViewModel?
Also: in debug mode i noticed that the "ProductDetailsViewModel"-getter is accessed only once per item after expanding the row. Collapsing and expanding the same row does not access the getter again.
UPDATE:
Another approach, same effect: I say my ItemsSource is a collection of ProductDetailsViewModel and inherit my MainViewModel from Conductor<ProductDetailsViewModel
>.Collection.OneActive, make the Grid binding with
ItemsSource = "{Binding Items}"
and in the xaml
<ContentControl cal:View.Model="{Binding DataContext.ActiveItem, RelativeSource={RelativeSource FindAncestor, AncestorType=telerik:RadGridView}}" />
in the SelectionChanged I do
ActivateItem(e.Row.Item as ProductDetailsViewModel);
Same as before, the ProductDetailsView is displayed for the current item, but disappears once I show the details of another product.