Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
 
<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 26-Sep-12 3:10am
Edited 26-Sep-12 20:11pm
(no name)105.8K
v2
Comments
Tilak Raheja at 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)



Advertise | Privacy | Mobile
Web01 | 2.8.141220.1 | Last Updated 27 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100