Hi Everyone,
I am working on XamGrid Infragistics and i want to display button with data in column . As shown in image.
Hello Vai,
Thank you for contacting Infragistics. The XamGrid allows TemplatedColumns which expose a ItemTemplate and EditorTemplate for cells when in or out of edit mode.
eg.
<ig:TemplateColumn Key="UnitPrice"> <ig:TemplateColumn.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding UnitPrice}" /> </DataTemplate> </ig:TemplateColumn.ItemTemplate> <!-- Set custom editor for column --> <ig:TemplateColumn.EditorTemplate> <DataTemplate> <StackPanel Orientation="Vertical"> <!-- Set UpdateSourceTrigger to Explicit so that grid has control over when update to source occurs --> <Slider x:Name="slider1" Minimum="0" Maximum="100" SmallChange="1" LargeChange="5" Value="{Binding UnitPrice, Mode=TwoWay, UpdateSourceTrigger=Explicit}"></Slider> <TextBlock Text="{Binding Value, ElementName=slider1}" HorizontalAlignment="Center"/> </StackPanel> </DataTemplate> </ig:TemplateColumn.EditorTemplate> </ig:TemplateColumn>
Let me know if you have any questions.
I need Button in place of slider or Textblock line shown in image
The following example is a more accurate demonstration of the required XAML required to achieve your requirement. I also attached a sample for more details.
<Grid> <ig:XamGrid ItemsSource="{Binding}" AutoGenerateColumns="False" > <ig:XamGrid.Columns> <ig:TextColumn Key="FirstName"> <ig:TextColumn.HeaderTemplate> <DataTemplate> <TextBlock HorizontalAlignment="Center" Text="Text" /> </DataTemplate> </ig:TextColumn.HeaderTemplate> </ig:TextColumn> <ig:TemplateColumn Key="LastName"> <ig:TemplateColumn.ItemTemplate> <DataTemplate> <StackPanel> <StackPanel Orientation="Horizontal"> <TextBlock HorizontalAlignment="Left" Text="{Binding LastName}" Margin="5,0,10,0" /> <Button Width="50" HorizontalAlignment="Right" > <Button.Content> <TextBlock> <Run Text="Button"> </Run> <Run Text="{Binding LastName}"> </Run> </TextBlock> </Button.Content> </Button> </StackPanel> </StackPanel> </DataTemplate> </ig:TemplateColumn.ItemTemplate> </ig:TemplateColumn> </ig:XamGrid.Columns> </ig:XamGrid> </Grid>
WpfApplication1.zip
Yes Button is coming Correctly But my Text is Repeating For All Columns Result is Weird
Thank you for following up. I don't see any repeating text, but there appears to a binding issue and you are only getting the type to display as the text instead of the value you want. Please modify my sample to demonstrate the issue and I'll investigate your bindings for you. Otherwise please provide any relevant code/XAML related to the xamgrid.