Parameters when using Interaction triggers, are there restrictions?

Feb 3, 2011 at 5:28 PM

In this code, taken straight from the documentation, I am simply trying to use a DataGrid instead of a TextBox.Text as a parameter.  So I set the name of my DataGrid via ElementName, however, Path is not applicable, as I want to pass in the whole DataGrid as a param.  Is this possible ?  (note: I am using this exact code and swapping out TextBox for a DataGrid)

 

<UserControl x:Class="Caliburn.Micro.HelloParameters.ShellView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
             xmlns:cal="http://www.caliburnproject.org">
    <StackPanel>
        <TextBox x:Name="Name" />
        <Button Content="Click Me">
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="Click">
                    <cal:ActionMessage MethodName="SayHello">
                        <cal:Parameter Value="{Binding ElementName=Name, Path=Text}" />
                    </cal:ActionMessage>
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </Button>
    </StackPanel>
</UserControl> 
Coordinator
Feb 3, 2011 at 5:49 PM

I don't think databinding expressions support ElementName without a path. I could be wrong.

Feb 3, 2011 at 5:58 PM
EisenbergEffect wrote:

I don't think databinding expressions support ElementName without a path. I could be wrong.

I would say you're probably right :)  Anyhow, I will pursue a different approach.  Thanks.

Feb 3, 2011 at 7:20 PM

Try:

<cal:Parameter Value="{Binding ElementName=Name, Path=.}" />