Hi,
I unable to bind the textblock inside datatemplate inside datatrigger of Xamgrid. Kindly suggest solution to bind. I think i m missing incorrect binding.
<efwc:EclpXamGrid Name="uxtest" HorizontalAlignment="Stretch" Grid.Row="2" Margin="2,2,0,0" AutoGenerateColumns="False" ItemsSource="{Binding FOO, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
<efwc:EclpXamGrid.Columns> <ig:TextColumn Key="ID" HeaderText="ID" ></ig:TextColumn> <ig:TemplateColumn Key="EntityContextName" HorizontalContentAlignment="Center"> <ig:TemplateColumn.HeaderTemplate> <DataTemplate> <TextBlock Text="Context" /> </DataTemplate> </ig:TemplateColumn.HeaderTemplate> <ig:TemplateColumn.CellStyle> <Style TargetType="ig:CellControl"> <Style.Triggers> <DataTrigger Binding="{Binding Name}" Value="A"> <Setter Property="ContentTemplate"> <Setter.Value> <DataTemplate> <TextBlock Text="{Binding Name}" ></TextBlock> <TextBox Text="{Binding Occupation}" /> </DataTemplate> </Setter.Value> </Setter> </DataTrigger> <DataTrigger Binding="{Binding EntityContextName}" Value="B"> <Setter Property="ContentTemplate"> <Setter.Value> <DataTemplate> <TextBlock Text="{Binding Name}" ></TextBlock> <TextBox Text="{Binding MobileNO }" /> </DataTemplate> </Setter.Value> </Setter> </DataTrigger> </Style.Triggers> </Style> </ig:TemplateColumn.CellStyle> </ig:TemplateColumn> </efwc:EclpXamGrid.Columns></efwc:EclpXamGrid>
Both controls are textblock inside every datatemplate. It was typing error.
Hi Vikas,
Try changing the binding to look like this:<TextBlock Text="{Binding Path=DataContext.Name}"/>
The DataContext of the template content seems to be a ContentPresenter, not the item, so you need to get to the item through the ContentPresenter's DataContext.