How can I detect when a DataGridRow's RowDetails has a non-empty DataTemplate?
I have a DataGrid that uses a DataTemplateSelector to select a Row Details DataTemplate, depending on the item object that's passed into the selector's SelectTemplate method. If no appropriate DataTemplate 开发者_开发问答can be found, the selector intentionally returns new DataTemplate().
What I want to do is detect if the DataGridDetailsPresenter will actually have meaningful content to display. Specifically, is the DataTemplate it's displaying just a new DataTemplate() or one that has content? If the DataTemplate has actual content, I want to use a DataTrigger to change the DataGridDetailsPresenter. So, something like:
<DataGridDetailsPresenter
Grid.Row="1"
SelectiveScrollingGrid.SelectiveScrollingOrientation="{Binding AreRowDetailsFrozen, ConverterParameter={x:Static SelectiveScrollingOrientation.Vertical}, Converter={x:Static DataGrid.RowDetailsScrollingConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" Visibility="{TemplateBinding DetailsVisibility}"
>
<DataGridDetailsPresenter.Style>
<Style
TargetType="{x:Type DataGridDetailsPresenter}"
>
<Style.Triggers>
<DataTrigger
Binding=*binding here*
Value="True"
>
<Setter
Property="Margin"
Value="4"
/>
Is there something I can bind to that will provide that information?
精彩评论