微软行为类
引用命名空间:
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
通过行为类,可以为控件添加触发器
<ScrollViewer Grid.Row="1"> <ItemsControl ItemsSource="{Binding ToDoDtos}" HorizontalAlignment="Center"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <WrapPanel/> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ItemsControl.ItemTemplate> <DataTemplate> <md:TransitioningContent OpeningEffect="{md:TransitionEffect Kind=ExpandIn}"> <Grid Margin="8" Width="220" MinHeight="180" MaxHeight="250"> <!--微软行为事件,事件名:MouseLeftButtonUp 控件名:ItemsControl--> <i:Interaction.Triggers> <i:EventTrigger EventName="MouseLeftButtonUp"> <i:InvokeCommandAction CommandParameter="{Binding }" Command="{Binding DataContext.SelectedCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ItemsControl}}"/> </i:EventTrigger> </i:Interaction.Triggers> <Grid.RowDefinitions> <RowDefinition Height="auto"/> <RowDefinition/> </Grid.RowDefinitions> <md:PopupBox HorizontalAlignment="Right" Panel.ZIndex="1"> <Button Content="删除"/> </md:PopupBox> <Border CornerRadius="3" Grid.RowSpan="2" Background="Green"/> <TextBlock FontWeight="Bold" Padding="10,5" Text="{Binding Title}"/> <TextBlock Padding="10,5" Text="{Binding Content}" Grid.Row="1"/> <Canvas Grid.RowSpan="2" ClipToBounds="True"> <Border CornerRadius="100" Canvas.Top="10" Canvas.Right="-50" Width="120" Height="120" Background="#FFFFFF" Opacity="0.1"/> <Border CornerRadius="100" Canvas.Top="80" Canvas.Right="-30" Width="120" Height="120" Background="#FFFFFF" Opacity="0.2"/> </Canvas> </Grid> </md:TransitioningContent> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> </ScrollViewer>