我尝试点击编辑时TextBlock
更改by但DataTemplate
对我没有更改listViewItem
VisualState
我的观点
<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 中的布尔属性。