附加到 GridViewColumnHeader 模板中的操作
我有一个 GridView 列:
public class SortableGridViewColumn : GridViewColumn
{
public string SortPropertyName
{
get { return (string)GetValue(SortPropertyNameProperty); }
set { SetValue(SortPropertyNameProperty, value); }
}
public static readonly DependencyProperty SortPropertyNameProperty =
DependencyProperty.Register("SortPropertyName", typeof(string),
typeof(SortableGridViewColumn), new UIPropertyMetadata(""));
}
和一个 GridViewColumnHeader 模板
<GridView.ColumnHeaderContainerStyle>
<Style TargetType="GridViewColumnHeader">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type GridViewColumnHeader}">
<Border cal:Message.Attach="[Event MouseLeftButtonDown]
= [Action Sort($source.TemplatedParent)]">
<ContentPresenter Margin="2,2,2,2" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style></GridView.ColumnHeaderContainerStyle>
而不是 $source.TemplatedParent
我想以某种方式传递 SortPropertyName 作为参数。
有人知道我怎样才能做到这一点吗?
感谢您的帮助,如果我没有正确询问,请抱歉 - 这是我的第一个问题。
I have a GridView column:
public class SortableGridViewColumn : GridViewColumn
{
public string SortPropertyName
{
get { return (string)GetValue(SortPropertyNameProperty); }
set { SetValue(SortPropertyNameProperty, value); }
}
public static readonly DependencyProperty SortPropertyNameProperty =
DependencyProperty.Register("SortPropertyName", typeof(string),
typeof(SortableGridViewColumn), new UIPropertyMetadata(""));
}
And a GridViewColumnHeader template
<GridView.ColumnHeaderContainerStyle>
<Style TargetType="GridViewColumnHeader">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type GridViewColumnHeader}">
<Border cal:Message.Attach="[Event MouseLeftButtonDown]
= [Action Sort($source.TemplatedParent)]">
<ContentPresenter Margin="2,2,2,2" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style></GridView.ColumnHeaderContainerStyle>
Instead of $source.TemplatedParent
I'd like to somehow pass SortPropertyName as a parameter.
Would anyone know how I could accomplish this?
Thanks for any help and sorry if I'm not asking properly - this is my first question here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否尝试过
不确定这是否有效...您也可以尝试添加样式设置器(不是在边框上,而是在 GridViewColumnHeaderStyle 上)。就像这样:
这只是一些即时的猜测。如果有什么效果请告诉我。如果没有,请随时在 Caliburn 论坛上发帖并附上示例。
Have you tried
Not sure that will work...You also might try adding a style setter instead (not on the border, but on the GridViewColumnHeaderStyle). So like this:
That's just a couple guesses off hand. Let me know if anything works. If not, feel free to post on the Caliburn forums and attach a sample.