重写 WPF GridViewRowPresenter 的单元格模板
我正在生成一个使用 GridViewRowPresenter 以类似于 ListView< 的方式/a> 确实 - 绑定到我的控件上 ViewBase:
<GridViewRowPresenter Content="{Binding Content}"
Columns="{Binding Path=View.Columns, RelativeSource={RelativeSource AncestorType={x:Type local:MyControlType}}}" />
这意味着控件的用户能够使用熟悉的 GridView 指定列code> 样式语法,例如:
<MyControlType><MyControlType.View><GridView>
<GridViewColumn Header="Name" DisplayMemberBinding="{Binding Name}" />
<GridViewColumn Header="Address" CellTemplate="{StaticResource MyCellTemplate}" />
</GridView></MyControlType.View></MyControlType>
这工作正常,但是我的控件(MyControlType
)需要能够“覆盖”网格中列的单元格模板,以便它们包含一些附加内容。
如何在对控件用户需要编写的语法进行最小更改的情况下完成此操作?
I'm producing a custom control that uses a GridViewRowPresenter in a similar way to the way that the ListView does - binding to the Columns
collection of a View
property on my control which is of type ViewBase:
<GridViewRowPresenter Content="{Binding Content}"
Columns="{Binding Path=View.Columns, RelativeSource={RelativeSource AncestorType={x:Type local:MyControlType}}}" />
This means that users of the control are able to specify the columns using the familiar GridView
style syntax, for example:
<MyControlType><MyControlType.View><GridView>
<GridViewColumn Header="Name" DisplayMemberBinding="{Binding Name}" />
<GridViewColumn Header="Address" CellTemplate="{StaticResource MyCellTemplate}" />
</GridView></MyControlType.View></MyControlType>
This works fine, however my control (the MyControlType
) need to be able to "override" the cell template for the columns in my grid so that they includes some additional content.
How can I do this with minimal change to the syntax users of the control need to write?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论