2

我尝试点击编辑时TextBlock 更改by但DataTemplate对我没有更改listViewItemVisualState

我的观点

<Page
................

DataContext="{Binding Categories, Source={StaticResource Locator}}"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Page.Resources>
    <DataTemplate x:Key="Template">
        <local:MyTemplate Width="393"/>
    </DataTemplate>
</Page.Resources>
<Grid x:Name="Layout">
    <Grid.RowDefinitions>
        <RowDefinition Height="60"/>
        <RowDefinition/>
    </Grid.RowDefinitions>
    <TextBlock Text="{Binding EditText}" Margin="10" FontSize="25" HorizontalAlignment="Right" VerticalAlignment="Center">
         <i:Interaction.Behaviors>
            <core:EventTriggerBehavior EventName="Tapped">
                <core:InvokeCommandAction Command="{Binding EditCommand}"/>
            </core:EventTriggerBehavior>
        </i:Interaction.Behaviors>
    </TextBlock>
    <ListView  Grid.Row="1"
               ItemsSource="{Binding AllCategories}"
               ItemTemplate="{StaticResource Template}"
               SelectionMode="Single"
               SelectedItem="{Binding SelectedItem, Mode=TwoWay}">
    </ListView>
 </Grid>

和我的用户控件

<UserControl>

.....................................

    <VisualStateManager.VisualStateGroups>
        <VisualStateGroup x:Name="TamplateState">
            <VisualState x:Name="EditeState">
                <Storyboard>
                ........................................................
                </Storyboard>
            </VisualState>
            <VisualState x:Name="Default"/>
        </VisualStateGroup>
    </VisualStateManager.VisualStateGroups>
    <i:Interaction.Behaviors>
        <core:DataTriggerBehavior Binding="{Binding IsEdit}" Value="True">
            <core:GoToStateAction StateName="EditeState"/>
        </core:DataTriggerBehavior>
        <core:DataTriggerBehavior Binding="{Binding IsEdit}" Value="False">
            <core:GoToStateAction StateName="Default"/>
        </core:DataTriggerBehavior>
    </i:Interaction.Behaviors>
</Grid>

IsEdit是 viewMoedl 中的布尔属性。

4

1 回答 1

0

我被belend修好了

<i:Interaction.Behaviors>
        <core:DataTriggerBehavior x:Name="dataTriggerBehavior" Binding="{Binding Main.IsEdit, Source={StaticResource Locator}}" Value="True">
            <core:GoToStateAction StateName="EditeState"/>
        </core:DataTriggerBehavior>
        <core:DataTriggerBehavior Binding="{Binding Main.IsEdit, Source={StaticResource Locator}}" Value="False">
            <core:GoToStateAction StateName="Default"/>
        </core:DataTriggerBehavior>
    </i:Interaction.Behaviors>
</Grid>
于 2015-07-27T21:43:19.853 回答