tags:

views:

170

answers:

1

I have a greed view 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.

Anyone knows how?

Thanks for any help and sorry if I'm not asking properly - this is my first question here.

A: 

Have you tried

[Event MouseLeftButtonDown] = [Action Sort($source.TemplatedParent.SortPropertyName)]

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:

<Setter Property="cal:Message.Attach"
        Value="[Event MouseLeftButtonDown] = [Action Sort($source.SortPropertyName)]" />

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.

EisenbergEffect