Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
HTML
<UserControl xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"  x:Class="MVVMEventTriggerDemo.Views.MainView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:viewModel="clr-namespace:MVVMEventTriggerDemo.ViewModels"
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:si="clr-namespace:Expression.Samples.Interactivity;assembly=Expression.Samples.Interactivity"
    Height="600" Width="700">
    <UserControl.Resources>
        <viewModel:MainViewModel x:Key="MainViewmodel"/>
    </UserControl.Resources>

    <Grid x:Name="LayoutRoot" removed="White" DataContext="{StaticResource MainViewmodel}">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="258*" />
            <ColumnDefinition Width="262*" />
        </Grid.ColumnDefinitions>
        <TextBox x:Name="t1" Text="{Binding EmployeeName, Mode=TwoWay}" Width="100" Height="30" Margin="142,77,20,289" Grid.Column="1">
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="TextChanged">
                    <si:CallDataMethod Method="UpdateText"/>
                    <si:ShowMessageBox Caption="Thank you"
                                       Message="Thanks for trying the Example"
                                       MessageBoxButton="OK"/>
                    <si:SetProperty TargetName="t1" PropertyName="Background" Value="PaleGoldenrod"/>
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </TextBox>

<-- Till here working is ok of textBox with UpdateText- Command.-->
<--But in dataGrid's textBox No Command gets fired -->
 <sdk:DataGrid 
            x:Name="dgDevice" 
            AutoGenerateColumns="False" 
            Margin="13,13,13,13"
            BorderThickness="1,0,1,1"
            RowBackground="White"
            VerticalScrollBarVisibility="Auto" Width="320" 
            Opacity="0.9"
            removed="White"
            GridLinesVisibility="None"
            HeadersVisibility="None"
            HorizontalScrollBarVisibility="Disabled"
            ItemsSource="{Binding ActualColors,Mode=TwoWay}">
            <sdk:DataGrid.Columns>
                <sdk:DataGridTemplateColumn Width="320" >
                    <sdk:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Grid Width="auto">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="30*"  />                                  
                                </Grid.ColumnDefinitions>
                               
                              <TextBox x:Name="t21" Text="{Binding Start, Mode=TwoWay}" Width="100" Height="30" Margin="142,77,20,289" Grid.Column="1">
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="TextChanged">
                    <si:CallDataMethod Method="UpdateText"/>
                    <si:ShowMessageBox Caption="Thank you"
                                       Message="Thanks for trying the Example"
                                       MessageBoxButton="OK"/>
                    <si:SetProperty TargetName="t21" PropertyName="Background" Value="PaleGoldenrod"/>
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </TextBox>

                            </Grid>
                        </DataTemplate>
                    </sdk:DataGridTemplateColumn.CellTemplate>
                </sdk:DataGridTemplateColumn>
            </sdk:DataGrid.Columns>
        </sdk:DataGrid>
</Grid>
</UserControl>

Please Provide me a solution for this. [ Updateext is a method in MVVM class]
Thanks for your favor !
Posted
Updated 26-Sep-12 19:11pm
v2
Comments
[no name] 26-Sep-12 13:58pm    
Is there any error by chance?
Can you ask something specific?
Tilak Raheja 27-Sep-12 1:51am    
Yes ofcourse !
Method 'UpdateText' in Texbox(t1)[in the Grid] is working fine. But textbox (t2) in DataGrid doesn't invoke the Method 'UpdateText' at all.
I want to know why the method 'UpdateText' in the textbox(t2)[in the Datagrid-Template]
is not working ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900