Phone 8.1 EventTriggerBehavior将参数传递给转换器

时间:2014-08-19 06:34:46

标签: xaml win-universal-app

我的Phone 8.1通用应用程序中有以下XAML标记

<Grid x:Name="AuthProviders" >
    <interactivity:Interaction.Behaviors>
        <core:EventTriggerBehavior EventName="Tapped">
            <core:InvokeCommandAction 
                Command="{Binding LoginCommand, Mode=OneWay}"
                InputConverter="{StaticResource GridItemSelConverter}"/>
        </core:EventTriggerBehavior>
    </interactivity:Interaction.Behaviors>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto"/>
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>
    <ListView x:Name="AuthenticationProviders"  ItemsSource="{Binding AuthenticationProviders}">
        <ListView.ItemTemplate>
            <DataTemplate>
                <StackPanel>                        
                    <Button Style="{StaticResource LoginButtonStyle}">
                        <Button.Content>
                            <Image Source="{Binding Name, Converter={StaticResource LoginConverter}}"/>
                        </Button.Content>
                    </Button>
                </StackPanel>
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>
</Grid>

现在在GridItemSelConverter中我需要包含以下代码

return ((value as TappedRoutedEventArgs).OriginalSource as FrameworkElement).DataContext as MyActualDataModel

我不喜欢这个因为我需要获得原始资源并且有很多转换,有没有更简单的方法来获取底层数据模型而不是这样?

0 个答案:

没有答案