Change background color of checked combobox in datagridview on button click using MVVM - c#-4.0

Hi I am new in WPF I want change background color of selected row. please help me in this
Itemsource for datagrid id Data property which is INotify Used to crate combobox (This Work Fine)
IsChecked is Property for Checkbox
please note that combobox and check box are dynamically created
<DataGrid Name="lbUsers" ItemsSource="{Binding Data}" CanUserAddRows="False" Grid.Column="1" Grid.Row="1" SelectedIndex="{Binding SelectionIndexChange, Mode=TwoWay}" AutoGenerateColumns="False">
<DataGrid.Columns>
<DataGridTemplateColumn Header="Rule Type" Width="100">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=DataContext.RuleType}"></TextBlock>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
<DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<ComboBox ItemsSource="{Binding Path=DataContext.RuleType, Mode=TwoWay, RelativeSource={RelativeSource AncestorType={x:Type Window}}}"
/>
</DataTemplate>
</DataGridTemplateColumn.CellEditingTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<CheckBox Width="45" Height="20" IsChecked="{Binding ElementName=lbUsers,Path=DataContext.IsChecked}" ></CheckBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns

<DataGrid ItemsSource="{Binding Data}" CanUserAddRows="False" Grid.Column="1" Grid.Row="1" SelectedIndex="{Binding SelectionIndexChange, Mode=TwoWay}" AutoGenerateColumns="False">
<DataGrid.ItemContainerStyle>
<Style TargetType="DataGridRow">
<Style.Triggers>
<DataTrigger Binding="{Binding IsChecked}" Value="True">
<Setter Property="Background" Value="Yellow" />
</DataTrigger>
</Style.Triggers>
</Style>
</DataGrid.ItemContainerStyle>
<DataGrid.Columns>
<DataGridTemplateColumn Header="Rule Type" Width="100">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding RuleType}"></TextBlock>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
<DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<ComboBox ItemsSource="{Binding Path=DataContext.RuleType, Mode=TwoWay, RelativeSource={RelativeSource AncestorType={x:Type Window}}}" />
</DataTemplate>
</DataGridTemplateColumn.CellEditingTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<CheckBox Width="45" Height="20" IsChecked="{Binding IsChecked}"></CheckBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>

Related

Align radio button to right side of popup

I have a popup for select colors.
<Popup x:Name="colorSelectorPopup">
<Border BorderThickness="1" BorderBrush="Gray">
<StackPanel HorizontalAlignment="Stretch">
<Grid x:Name="colorSelectorTitle" Height="40" VerticalAlignment="Top">
<TextBlock x:Name="popupTitle" TextTrimming="CharacterEllipsis" FontSize="16" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="8"/>
</Grid>
<ListView x:Name="colorList" HorizontalAlignment="Stretch" Background="White">
<ListView.ItemTemplate>
<DataTemplate>
<Grid HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" x:Name="tbColor" Text="{Binding ColorName}" Foreground="{Binding ForegroundColor}" HorizontalAlignment="Left"/>
<RadioButton Grid.Column="1" x:Name="radioColor" GroupName="colorRadio" Tag="{Binding SelectionColor}" MinWidth="32" Checked="radioColor_Checked"/>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackPanel>
</Border>
</Popup>
I want the radio button to show on the right side. But It looks as in the image.
How can I move the radio button to the right side?
I got the answer from here.
By Adding the following xaml I got the desired output.
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
</Style>
</ListView.ItemContainerStyle>
This works for me. I have updated my xaml as follows
<Popup x:Name="colorSelectorPopup">
<Border BorderThickness="1" BorderBrush="Gray">
<StackPanel HorizontalAlignment="Stretch">
<Grid x:Name="colorSelectorTitle" Height="40" VerticalAlignment="Top">
<TextBlock x:Name="popupTitle" TextTrimming="CharacterEllipsis" FontSize="16" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="8"/>
</Grid>
<ListView x:Name="colorList" HorizontalAlignment="Stretch" Background="White">
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
</Style>
</ListView.ItemContainerStyle>
<ListView.ItemTemplate>
<DataTemplate>
<Grid HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" x:Name="tbColor" Text="{Binding ColorName}" Foreground="{Binding ForegroundColor}" HorizontalAlignment="Left"/>
<RadioButton Grid.Column="1" x:Name="radioColor" GroupName="colorRadio" Tag="{Binding SelectionColor}" MinWidth="32" Checked="radioColor_Checked"/>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackPanel>
</Border>
</Popup>
Since the grid only contains 2 columns and the 2nd column only contains the radio button I would set the column definition to a fixed with for the 2nd one instead of auto. see if that works.
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="40"/>
</Grid.ColumnDefinitions>

CheckBox DelegateCommand not firing

I have seen many similar questions posted, but I think mine may be different enough to warrant posting it.
I am simply migrating the sample Azure Mobile Services application to Windows 10 UWP and trying to keep everything MVVM. I have a ListView that has a DataTemplate that looks like this:
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<CheckBox Name="CheckBoxComplete"
Command="{Binding ElementName=ViewModel, Path=UpdateCommand}"
CommandParameter="{Binding}"
Margin="10,5"
VerticalAlignment="Center"
Content="{Binding Text}"
IsChecked="{Binding Complete,
Mode=TwoWay}" />
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
Everything compiles fine, but the UpdateCommand is not firing. I have set a breakpoint to make sure that the correct value would be passed as the CommandParameter, but the Command is not firing. Is it possible to use a DelegateCommand on a CheckBox that is inside of a DataTemplate?
Or will I have to use attached behaviors to achieve something like this?
EDIT
The original CheckBox looked like this, with the click event handler in the code-behind:
<CheckBox Name="CheckBoxComplete"
IsChecked="{Binding Complete, Mode=TwoWay}"
Checked="CheckBoxComplete_Checked"
Content="{Binding Text}"
Margin="10,5" VerticalAlignment="Center" />
EDIT2
Posting entire XAML by request:
<Page x:Class="MyMoney10.Views.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:behaviors="using:Template10.Behaviors"
xmlns:common="using:MyMoney10.Common"
xmlns:controls="using:Template10.Controls"
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
xmlns:local="using:MyMoney10.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:models="using:MyMoney10.Models"
xmlns:vm="using:MyMoney10.ViewModels"
mc:Ignorable="d">
<Page.DataContext>
<vm:MainPageViewModel x:Name="ViewModel" />
</Page.DataContext>
<RelativePanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<RelativePanel.ChildrenTransitions>
<TransitionCollection>
<EntranceThemeTransition />
</TransitionCollection>
</RelativePanel.ChildrenTransitions>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="AdaptiveVisualStateGroup">
<VisualState x:Name="VisualStateNarrow">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="{StaticResource NarrowMinWidth}" />
</VisualState.StateTriggers>
<VisualState.Setters>
<!-- TODO: change properties for narrow view -->
<!--<Setter Target="StateTextBox.Text" Value="Narrow Visual State" />-->
</VisualState.Setters>
</VisualState>
<VisualState x:Name="VisualStateNormal">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="{StaticResource NormalMinWidth}" />
</VisualState.StateTriggers>
<VisualState.Setters>
<!-- TODO: change properties for normal view -->
<!--<Setter Target="StateTextBox.Text" Value="Normal Visual State" />-->
</VisualState.Setters>
</VisualState>
<VisualState x:Name="VisualStateWide">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="{StaticResource WideMinWidth}" />
</VisualState.StateTriggers>
<VisualState.Setters>
<!-- TODO: change properties for wide view -->
<!--<Setter Target="StateTextBox.Text" Value="Wide Visual State" />-->
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<controls:PageHeader x:Name="PageHeader" Text="MyMoney">
<!-- place stretched, across top -->
<RelativePanel.AlignTopWithPanel>True</RelativePanel.AlignTopWithPanel>
<RelativePanel.AlignRightWithPanel>True</RelativePanel.AlignRightWithPanel>
<RelativePanel.AlignLeftWithPanel>True</RelativePanel.AlignLeftWithPanel>
<!-- secondary commands -->
<controls:PageHeader.SecondaryCommands>
<AppBarButton Click="{x:Bind ViewModel.GotoSettings}" Label="Settings" />
<AppBarButton Click="{x:Bind ViewModel.GotoPrivacy}" Label="Privacy" />
<AppBarButton Click="{x:Bind ViewModel.GotoAbout}" Label="About" />
</controls:PageHeader.SecondaryCommands>
</controls:PageHeader>
<controls:Resizer x:Name="ParameterResizer" Margin="16,16,16,0">
<!-- place below page header -->
<RelativePanel.Below>PageHeader</RelativePanel.Below>
<RelativePanel.AlignLeftWithPanel>True</RelativePanel.AlignLeftWithPanel>
<TextBox MinWidth="250"
MinHeight="62"
Header="Parameter to pass"
Text="{Binding Value,
Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}">
<interactivity:Interaction.Behaviors>
<!-- enable submit on enter key -->
<behaviors:KeyBehavior Key="Enter">
<core:CallMethodAction MethodName="GotoDetailsPage" TargetObject="{Binding}" />
</behaviors:KeyBehavior>
<!-- focus on textbox when page loads -->
<core:EventTriggerBehavior>
<behaviors:FocusAction />
</core:EventTriggerBehavior>
</interactivity:Interaction.Behaviors>
</TextBox>
</controls:Resizer>
<Button x:Name="SubmitButton"
Click="{x:Bind ViewModel.GotoDetailsPage}"
Content="Submit">
<!-- place next to textbox -->
<RelativePanel.RightOf>ParameterResizer</RelativePanel.RightOf>
<RelativePanel.AlignBottomWith>ParameterResizer</RelativePanel.AlignBottomWith>
</Button>
<TextBlock x:Name="StateTextBox"
Margin="16,16,0,0"
Text="Current Visual State">
<!-- place under to textbox -->
<RelativePanel.Below>ParameterResizer</RelativePanel.Below>
<RelativePanel.AlignLeftWith>ParameterResizer</RelativePanel.AlignLeftWith>
</TextBlock>
<Grid>
<RelativePanel.Below>StateTextBox</RelativePanel.Below>
<RelativePanel.AlignLeftWithPanel>True</RelativePanel.AlignLeftWithPanel>
<RelativePanel.AlignRightWithPanel>True</RelativePanel.AlignRightWithPanel>
<RelativePanel.AlignBottomWithPanel>True</RelativePanel.AlignBottomWithPanel>
<Grid Margin="50,50,10,10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid Grid.Row="0"
Grid.ColumnSpan="2"
Margin="0,0,0,20">
<StackPanel>
<TextBlock Margin="0,0,0,6"
FontFamily="Segoe UI Light"
Foreground="#0094ff">
MICROSOFT AZURE MOBILE SERVICES
</TextBlock>
<TextBlock FontFamily="Segoe UI Light"
FontSize="45"
Foreground="Gray">
MyMoney10
</TextBlock>
</StackPanel>
</Grid>
<Grid Grid.Row="1">
<StackPanel>
<common:QuickStartTask Title="Insert a TodoItem"
Description="Enter some text below and click Save to insert a new todo item into your database"
Number="1" />
<StackPanel Margin="72,0,0,0" Orientation="Horizontal">
<TextBox Name="TextInput"
MinWidth="300"
Margin="5" />
<Button Name="ButtonSave"
Command="{x:Bind ViewModel.SaveCommand}"
CommandParameter="{Binding ElementName=TextInput,
Path=Text}"
IsEnabled="{x:Bind ViewModel.SaveEnabled}">
Save
</Button>
</StackPanel>
</StackPanel>
</Grid>
<Grid Grid.Row="1" Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<StackPanel>
<common:QuickStartTask Title="Query and Update Data"
Description="Click refresh below to load the unfinished TodoItems from your database. Use the checkbox to complete and update your TodoItems"
Number="2" />
<Button Name="ButtonRefresh"
Margin="72,0,0,0"
Click="{x:Bind ViewModel.RefreshCommand}"
IsEnabled="{x:Bind ViewModel.RefreshEnabled}">
Refresh
</Button>
</StackPanel>
<ListView Name="ListItems"
Grid.Row="1"
Margin="62,10,0,0"
ItemsSource="{Binding TodoItems}">
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<CheckBox Name="CheckBoxComplete"
Margin="10,5"
VerticalAlignment="Center"
Command="{Binding ElementName=ViewModel,
Path=UpdateCommand}"
CommandParameter="{Binding}"
Content="{Binding Text}"
IsChecked="{Binding Complete,
Mode=TwoWay}" />
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</Grid>
</Grid>
</RelativePanel>
</Page>
So the checkbox binding to elementname="viewmodel" is the issue. Because viewmodel is not a name of an element.
So give your page a name and put that name in the binding. With path=Datacontext.UpdateCommand

stretch TextBlocks inside a Grid in a universal App

I am having a problem in fixing 3 TextBlocks inside a Grid,in a metro App,I used this link enter link description here
but I get always a problem in stretching my TextBlocks inside the Grid
this is my code:
<ListView Grid.Row="1" Grid.ColumnSpan="2" HorizontalAlignment="Stretch">
<ListView.ItemTemplate >
<DataTemplate>
<Grid Margin="0" HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Border Margin="0">
<Image Grid.Column="0" Source="images/img1.png" Margin="0,5" Stretch="Fill" Width="80"/>
</Border>
<Grid Grid.Column="1" Margin="5" HorizontalAlignment="Stretch" >
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock x:Name="text1" Text="test1" Grid.Row="0" Margin="5" HorizontalAlignment="Stretch" ></TextBlock>
<TextBlock x:Name="text2" Text="test2" Grid.Row="1" HorizontalAlignment="Stretch" ></TextBlock>
<TextBlock x:Name="text3" Text="test3" Grid.Row="2" HorizontalAlignment="Stretch" ></TextBlock>
</Grid>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
so please I need your help,to fix that
thanks for help
You have to edit style of ListViewItem and set HorizontalAlignment to Stretch
<ListView>
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="HorizontalAlignment"
Value="Stretch" />
<Setter Property="HorizontalContentAlignment"
Value="Stretch" />
</Style>
</ListView.ItemContainerStyle>
</ListView>

Gridview not scrolling horizontally in windows phone 8.1

.Gridview not scrolling horizontally in windows phone app instead it is scrolling vertically.I just copy paste the code of my windows 8.1 app to windows phone 8.1 but it is scrolling vertically.
here is the xaml code:
<Grid>
<Grid.Background>
<ImageBrush ImageSource="Assets/back3.png"></ImageBrush>
</Grid.Background>
<Grid.ChildrenTransitions>
<TransitionCollection>
<EntranceThemeTransition/>
</TransitionCollection>
</Grid.ChildrenTransitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="5*"/>
<RowDefinition Height=".6*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="70"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="Select Comic" Foreground="Black" FontSize="30" VerticalAlignment="Center" Grid.Row="0" Grid.Column="1"></TextBlock>
<!-- Back button and page title -->
<GridView x:Name="myGridview" Grid.Column="1" Grid.Row="1" SelectionChanged="myGridview_SelectionChanged">
<GridView.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,0,20,20">
<Image Source="{Binding source}" Width="100" Height="100" Stretch="Fill"></Image>
</StackPanel>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
</Grid>
Try by putting
ItemsPanel,ScrollViewer.HorizontalScrollMode="Enabled" ScrollViewer.HorizontalScrollBarVisibility="Visible"
<GridView Width="400" ScrollViewer.HorizontalScrollMode="Enabled" ScrollViewer.HorizontalScrollBarVisibility="Visible">
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Horizontal"></VirtualizingStackPanel>
</ItemsPanelTemplate>
</GridView.ItemsPanel>
<GridView.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,0,20,20">
<Image Source="{Binding source}" Width="100" Height="100" Stretch="Fill"></Image>
</StackPanel>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
Update
try by changing Itemspanel : WrapGrid Orientation="Vertical" or Orientation="Horizontal"
<GridView Width="400" ScrollViewer.HorizontalScrollMode="Enabled" ScrollViewer.HorizontalScrollBarVisibility="Visible">
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<WrapGrid Orientation="Vertical"></WrapGrid>
</ItemsPanelTemplate>
</GridView.ItemsPanel>
<GridView.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,0,20,20">
<Image Source="{Binding source}" Width="100" Height="100" Stretch="Fill"></Image>
</StackPanel>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>

Triggers on TextBox in DataGrid's DataTemplate are not Working

While working on MVVM in Silverlight 4.0. I got stuck with following problem.
See the following Xaml. And note that in TextBox1 the Method UpdateText (under interaction triggers) is working but in TextBox2 which is the part of DataGrid's Template,Here method 'UpdateText' is not working at all. Can anyone help me out to call a method on TextChanged Event of TextBox2?
(UpdateText is just a simple method in MVVM class working with TextBox1 but not with TextBox2)
Here is the xaml :
<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" Background="White" DataContext="{StaticResource MainViewmodel}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="258*" />
<ColumnDefinition Width="262*" />
</Grid.ColumnDefinitions>
<TextBox x:Name="textbox1" 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="textbox1" PropertyName="Background" Value="PaleGoldenrod"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</TextBox>
<Button Content="Show Message" Width="100" Height="25" Margin="142,113,20,258" Grid.Column="1">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<si:CallDataMethod Method="HandleShowMessage"/>
<si:ShowMessageBox Caption="Thank you"
Message="Thanks for trying the Example"
MessageBoxButton="OK"/>
<si:SetProperty TargetName="LayoutRoot" PropertyName="Background" Value="PaleGoldenrod"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
<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"
Background="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*" />
<ColumnDefinition Width="20*" />
</Grid.ColumnDefinitions>
<TextBox x:Name="textbox2" 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="textbox2" PropertyName="Background" Value="PaleGoldenrod"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</TextBox>
</Grid>
</DataTemplate>
</sdk:DataGridTemplateColumn.CellTemplate>
</sdk:DataGridTemplateColumn>
</sdk:DataGrid.Columns>
</sdk:DataGrid>
</Grid>
i not sure it can help you but in Datatemplate binding will goes like
<TextBlock Text="{Binding Path=DataContext.BusyText, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" />
i think you may have to bind event same as text bind in upper sentence.

Resources