<k:GridView Name="_masterGridView"
ItemsSource="{Binding ProductLocationList}"
SelectedItem="{Binding ProductLocationSelected}">
<!-- DataContext does not propagate here automatically in user control... why? -->
<k:GridView.ExportOptions>
<k:GridViewExportOptions Title="Production Location Management">
<k:SearchCriteria >
<k:SearchCriterion Title="End Date"
Value="{Binding SearchEndDate}"
ValueFormat="g" />
</k:SearchCriteria>
</k:GridViewExportOptions>
</k:GridView.ExportOptions>
<!-- to here -->
我必须做这个hack,它只传播到GridViewExport选项 黑客在GridView类中......
public GridViewExportOptions ExportOptions
{
get { return _exportOptions; }
set
{
_exportOptions = value;
if (value != null)
{
ExportOptions.SetBinding(FrameworkContentElement.DataContextProperty,
new Binding("DataContext")
{
Source = this,
Mode = BindingMode.TwoWay
});
}
}
}
答案 0 :(得分:4)
您需要将GridViewExportOptions
添加为逻辑子项。实际上,您的GridViewExportOptions
必须来自FrameworkElement
。更改属性后,您必须GridView
上的AddLogicalChild(和RemoveLogicalChild删除旧值,如果有的话)。然后,您必须覆盖GridView
上的LogicalChildren并包含您的选项。
您需要在GridViewExportOptions
课程中执行此操作,就其中的“孩子”而言。