文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>SilverLight触发器加Command命令实现双击行弹出窗体

SilverLight触发器加Command命令实现双击行弹出窗体

时间:2011-04-01  来源:记忆逝去的青春

效果预览:

 截图有点大。。。别介意哦。。。

言归正传:

xaml代码:

<Grid x:Name="LayoutRoot" Background="White">
            <Grid.RowDefinitions>
                <RowDefinition Height="30"></RowDefinition>
                <RowDefinition Height="270*"></RowDefinition>
                <RowDefinition Height="20"></RowDefinition>
            </Grid.RowDefinitions>
             <TextBlock FontSize="14" Margin="5" Grid.Row="0">库存总账条目:</TextBlock>
            <data:DataGrid x:Name="dglist" Grid.Row="1" Margin="5,0,5,0"  GridLinesVisibility="All"
                                   AutoGenerateColumns="False"
                                    FrozenColumnCount="1"
                         
                                      AreRowDetailsFrozen="True"  
                       HorizontalAlignment="Stretch" CanUserSortColumns="False"
                       ItemsSource="{Binding InvStockLedgerModelList,Mode=TwoWay}"
                       IsReadOnly="True" SelectedItem="{Binding InvStockLedgerModel,Mode=TwoWay}">

                <data:DataGrid.Columns>
                    <data:DataGridTextColumn Header="物料名称" Binding="{Binding MaterialModel.Mat_Name,Mode=TwoWay}"/>
                    <data:DataGridTextColumn Header="会计年度" Binding="{Binding StockLedger_Year,Mode=TwoWay}"/>
                    <data:DataGridTextColumn Header="会计期间" Binding="{Binding StockLedger_Period,Mode=TwoWay}"/>
                    <data:DataGridTextColumn Header="期初库存数量" Binding="{Binding StockLedger_BAmount,Mode=TwoWay}"/>
                    <data:DataGridTextColumn Header="期初库存金额" Binding="{Binding StockLedger_BMoney,Mode=TwoWay}" Width="100"/>
                    <data:DataGridTextColumn Header="收入数量" Binding="{Binding StockLedger_IAmount,Mode=TwoWay}"/>
                    <data:DataGridTextColumn Header="收入金额" Binding="{Binding StockLedger_IMoney,Mode=TwoWay}" Width="100"/>
                    <data:DataGridTextColumn Header="发出数量" Binding="{Binding StockLedger_OAmount,Mode=TwoWay}"/>
                    <data:DataGridTextColumn Header="发出金额" Binding="{Binding StockLedger_OMoney,Mode=TwoWay}" Width="100"/>
                    <data:DataGridTextColumn Header="期末数量" Binding="{Binding StockLedger_EndAmount,Mode=TwoWay}"/>
                    <data:DataGridTextColumn Header="期末金额" Binding="{Binding StockLedger_EndMoney,Mode=TwoWay}" Width="100"/>
                </data:DataGrid.Columns>

<!--内置两个触发器
                判断双击是否在同一行进行的-->
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="SelectionChanged">
                        <i:InvokeCommandAction Command="{Binding DataGridSelectionCommand}" CommandParameter="{Binding SelectedItem,ElementName=dglist}" />
                    </i:EventTrigger>
                    <i:EventTrigger EventName="MouseLeftButtonUp">
                        <i:InvokeCommandAction Command="{Binding MouseLeftButtonUpCommand}" CommandParameter="{Binding SelectedItem,ElementName=dglist}" />
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </data:DataGrid>

            <Border Grid.Row="2" BorderThickness="1,0,1,1" BorderBrush="#6c7175" Margin="5,0,5,0" >
            <Grid x:Name="gridFooter" HorizontalAlignment="Stretch"  VerticalAlignment="Top"  >
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <sdk:Label Content="合 计:" FontSize="13" />
                    <sdk:Label Grid.Column="3" FontSize="13" BorderThickness="1,0,0,0" BorderBrush="#6c7175" x:Name="lblStockLedger_BAmount" />
                    <sdk:Label Grid.Column="4" FontSize="13" BorderThickness="1,0,0,0" BorderBrush="#6c7175" x:Name="lblStockLedger_BMoney" />
                    <sdk:Label Grid.Column="5" FontSize="13" BorderThickness="1,0,0,0" BorderBrush="#6c7175" x:Name="lblStockLedger_IAmount" />
                    <sdk:Label Grid.Column="6" FontSize="13" BorderThickness="1,0,0,0" BorderBrush="#6c7175" x:Name="lblStockLedger_IMoney" />
                    <sdk:Label Grid.Column="7" FontSize="13" BorderThickness="1,0,0,0" BorderBrush="#6c7175" x:Name="lblStockLedger_OAmount"/>
                    <sdk:Label Grid.Column="8" FontSize="13" BorderThickness="1,0,0,0" BorderBrush="#6c7175" x:Name="lblStockLedger_OMoney" />
                    <sdk:Label Grid.Column="9" FontSize="13" BorderThickness="1,0,0,0" BorderBrush="#6c7175" x:Name="lblStockLedger_EndAmount"/>
                    <sdk:Label Grid.Column="10" FontSize="13" BorderThickness="1,0,0,0" BorderBrush="#6c7175" x:Name="lblStockLedger_EndMoney"/>
            </Grid>
            </Border>
    </Grid>

cs代码:

public DelegateCommand DataGridSelectionCommand { protected set; get; }//选择datagrid行命令
public DelegateCommand MouseLeftButtonUpCommand { protected set; get; }//单击行命令

DataGridSelectionCommand = new DelegateCommand(DoDataGridSelectionCommand);//命令初始化
MouseLeftButtonUpCommand = new DelegateCommand(DoMouseLeftButtonUpCommand);

  

//定义一个辅助变量 

public static bool IsDoubleClick = true; 
        void DoMouseLeftButtonUpCommand(object param)//执行单击命令
        {
            if (param == null) return;
            IsDoubleClick = !IsDoubleClick;
            if (!IsDoubleClick && InvStockLedgerModel == param as InvStockLedgerModel)//判断datagrid选择的行和单击行是不是同一行
            {

//绑定和显示子页面数据

//可以在此处写 弹出窗体及 绑定数据。。。。
                RequestService.Sent(StockManageUriNames.GetInvStockListModelList, InvStockLedgerModel,
                  delegate(object sent, ResponseArgs args)
                  {
                      var InvStockListModelList = Container.Resolve<IInvStockListViewModel>();
                      InvStockListModelList.InvStockListModelList = args.JsonResponse.GetPostData<IList<InvStockListModel>>();
                      InvStockListModelList.GetStockListSum();//计算合计行
                      InvStockListModelList.View.Show();//显示窗体
                  });
            }
        }
      
        void DoDataGridSelectionCommand(object param)//执行datagrid行选择命令
        {
            if(param==null)return;
            InvStockLedgerModel = param as InvStockLedgerModel;//将选择的行 赋予属性
            IsDoubleClick = View.ViewControl.dglist.SelectedIndex == -1;
        }

大功告成!!!

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载