码迷,mamicode.com
首页 > 其他好文 > 详细

CommandParameter binding Introduction:

时间:2014-07-19 22:03:14      阅读:290      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   os   width   

 

 

<Window x:Class="OddEvenRows.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid" 
        Height="400" Width="300" 
        xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
        xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras"
        xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" Title="JackSlater" x:Name="jackWindow">
    <Window.Resources>
        <FrameworkElement x:Key="ProxyElement" DataContext="{Binding Path=.,ElementName=noTB01}"/>
    </Window.Resources>
    <StackPanel>
        <ContentControl Visibility="Collapsed" Content="{StaticResource ProxyElement}"/>
        <StackPanel>
            <TextBlock x:Name="noTB01" Text="No.1"></TextBlock>
            <TextBlock x:Name="noTB02" Text="No.2"></TextBlock>
            <Button x:Name="testBtn" Content="Hello"></Button>
        </StackPanel>
        <Grid>
            <dxg:GridControl x:Name="gridControl" Grid.Row="2" MaxHeight="500" ItemsSource="{Binding MyList,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}">
                <dxg:GridControl.Columns>
                    <dxg:GridColumn FieldName="Index">
                        <dxg:GridColumn.CellTemplate>
                            <DataTemplate>
                                <dxe:ComboBoxEdit Name="PART_Editor" IsTextEditable="False" >
                                    <dxe:ComboBoxEditItem x:Name="readyCombox" Content="ClickDownComboxItem">
                                        <i:Interaction.Triggers>
                                            <i:EventTrigger EventName="PreviewMouseDown">
                                                <cmd:EventToCommand 
                                             Command="{Binding Path=View.DataContext.ImportCommand}"
                                             CommandParameter="{Binding Path=DataContext.Text, Source={StaticResource ProxyElement}}"/>
                                            </i:EventTrigger>
                                        </i:Interaction.Triggers>
                                    </dxe:ComboBoxEditItem>
                                </dxe:ComboBoxEdit>
                            </DataTemplate>
                        </dxg:GridColumn.CellTemplate>
                    </dxg:GridColumn>
                </dxg:GridControl.Columns>
                <dxg:GridControl.View>
                    <dxg:TableView AutoWidth="True"/>
                </dxg:GridControl.View>
            </dxg:GridControl>
        </Grid>
    </StackPanel>
</Window>

 

<Window x:Class="OddEvenRows.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid" 
        Height="400" Width="300" 
        xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
        xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras"
        xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" Title="JackSlater" x:Name="jackWindow">
    <dxg:GridControl x:Name="gridControl"  ItemsSource="{Binding MyList,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}">
                <dxg:GridControl.Columns>
                    <dxg:GridColumn FieldName="Index">
                        <dxg:GridColumn.CellTemplate>
                            <DataTemplate>
                                <dxe:ComboBoxEdit EditValue="{Binding Data.Index,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" IsTextEditable="False" >
                                    <dxe:ComboBoxEditItem x:Name="readyCombox" Content="ClickDownComboxItem">
                                        <i:Interaction.Triggers>
                                            <i:EventTrigger EventName="PreviewMouseDown">
                                                <cmd:EventToCommand 
                                             Command="{Binding Path=View.DataContext.ImportCommand}"
                                             CommandParameter="{Binding Path=View.DataControl.Parent}"/>
                                            </i:EventTrigger>
                                        </i:Interaction.Triggers>
                                    </dxe:ComboBoxEditItem>
                                </dxe:ComboBoxEdit>
                            </DataTemplate>
                        </dxg:GridColumn.CellTemplate>
                    </dxg:GridColumn>
                </dxg:GridControl.Columns>
                <dxg:GridControl.View>
                    <dxg:TableView AutoWidth="True"/>
                </dxg:GridControl.View>
            </dxg:GridControl>
</Window>

 

<Window x:Class="OddEvenRows.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid" 
        Height="400" Width="300" 
        xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
        xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras"
        xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" Title="JackSlater" x:Name="jackWindow">
    <Window.Resources>
        <!--<FrameworkElement x:Key="ProxyElement" DataContext="{Binding noTB01}"/>-->
        <TextBlock x:Key="ProxyElement" DataContext="{Binding Path=.,ElementName=noTB01}"/>
    </Window.Resources>
    <StackPanel>
        <ContentControl Visibility="Collapsed" Content="{StaticResource ProxyElement}"/>
        <StackPanel>
            <TextBlock x:Name="noTB01" Text="No.1"></TextBlock>
            <TextBlock x:Name="noTB02" Text="No.2"></TextBlock>
            <Button x:Name="testBtn" Content="Hello"></Button>
        </StackPanel>
        <Grid>
            <dxg:GridControl x:Name="gridControl" Grid.Row="2" MaxHeight="500" ItemsSource="{Binding MyList,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}">
                <dxg:GridControl.Columns>
                    <dxg:GridColumn FieldName="Index">
                        <dxg:GridColumn.CellTemplate>
                            <DataTemplate>
                                <dxe:ComboBoxEdit Name="PART_Editor" IsTextEditable="False" >
                                    <dxe:ComboBoxEditItem x:Name="readyCombox" Content="ClickDownComboxItem">
                                        <i:Interaction.Triggers>
                                            <i:EventTrigger EventName="PreviewMouseDown">
                                                <cmd:EventToCommand 
                                             Command="{Binding Path=View.DataContext.ImportCommand}"
                                             CommandParameter="{Binding Path=DataContext.Text,Source={StaticResource ProxyElement}}"/>
                                            </i:EventTrigger>
                                        </i:Interaction.Triggers>
                                    </dxe:ComboBoxEditItem>
                                </dxe:ComboBoxEdit>
                            </DataTemplate>
                        </dxg:GridColumn.CellTemplate>
                    </dxg:GridColumn>
                </dxg:GridControl.Columns>
                <dxg:GridControl.View>
                    <dxg:TableView AutoWidth="True"/>
                </dxg:GridControl.View>
            </dxg:GridControl>
        </Grid>
    </StackPanel>
</Window>

 

http://www.thomaslevesque.com/2011/03/21/wpf-how-to-bind-to-data-when-the-datacontext-is-not-inherited/

http://stackoverflow.com/questions/7660967/wpf-error-cannot-find-govering-frameworkelement-for-target-element

http://stackoverflow.com/questions/7660967/wpf-error-cannot-find-govering-frameworkelement-for-target-element

DevExpressCenter:

http://www.devexpress.com/Support/Center/Question/Details/T129527

CommandParameter binding Introduction:,布布扣,bubuko.com

CommandParameter binding Introduction:

标签:style   blog   http   color   os   width   

原文地址:http://www.cnblogs.com/jackslateryu/p/3849235.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!