zoukankan      html  css  js  c++  java
  • StackPanel Binding

    注意<i:Interaction>需要使用Blend的System.Windows.Interactivity.dll文件。

    Xaml文件:

    <StackPanel Width="200" Height="auto" MaxHeight="400" Grid.Row="1">
      <ItemsControl ItemsSource="{Binding MenuSet}">
      <ItemsControl.ItemsPanel>
        <ItemsPanelTemplate>
          <StackPanel HorizontalAlignment="Center" IsItemsHost="True"></StackPanel>
        </ItemsPanelTemplate>
      </ItemsControl.ItemsPanel>
      <ItemsControl.ItemTemplate>
        <DataTemplate>
          <TextBlock Text="{Binding Name}" Name="txtb">
            <i:Interaction.Triggers>
            <i:EventTrigger EventName="MouseLeftButtonDown">
        

              <i:InvokeCommandAction CommandParameter="{Binding ElementName=txtb}"
              Command="{Binding Path=DataContext.ModifyCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type            StackPanel}}}">

            </i:InvokeCommandAction>

            </i:EventTrigger>
            </i:Interaction.Triggers>
          </TextBlock>
        </DataTemplate>
      </ItemsControl.ItemTemplate>
     </ItemsControl>
    </StackPanel>

     

     

    ViewModel: 注意DelegateCommand需要Prism中的Microsoft.Practices.Prism.dll。

    Model:

  • 相关阅读:
    Girls and Boys
    Kindergarten
    codevs 2822 爱在心中
    Popular Cows
    QWQ
    2488 绿豆蛙的归宿(拓扑+dp)
    P1119 灾后重建
    Mr. Frog’s Game
    Basic Data Structure
    A strange lift
  • 原文地址:https://www.cnblogs.com/gnsds/p/3632259.html
Copyright © 2011-2022 走看看