Hello,
I would like to use the same key on further columns on Xamgrid, how can i do ?
At the moment i have an error on this point.
I'm doing something like this :
<ig:XamGrid x:Name="dataGrid" ItemsSource="{Binding Orders}">
<ig:XamGrid.Columns>
<ig:TemplateColumn Key="Order" HeaderText="Update"> <ig:TemplateColumn.ItemTemplate> <DataTemplate> <Button Style="{StaticResource EditButtonStyle}" Height="18" Command="{Binding DataContext.DrawOrderDetail,RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ig:XamGrid}}}" CommandParameter="{Binding Order}"></Button> </DataTemplate> </ig:TemplateColumn.ItemTemplate> </ig:TemplateColumn> <ig:TemplateColumn Key="Order" HeaderText="PDF"> <ig:TemplateColumn.ItemTemplate> <DataTemplate> <Button Style="{StaticResource FlatIconeButton}" BorderBrush="White" Background="White" Command="{Binding DataContext.DrawPDFCommand,RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ig:XamGrid}}}" CommandParameter="{Binding Order}" <ContentControl Style="{StaticResource PDF_ContentControlStyle}" BorderBrush="Black"/> </Button> </DataTemplate> </ig:TemplateColumn.ItemTemplate> </ig:TemplateColumn >
</ig:XamGrid.Columns>
</xamgrid>
I just want to add button for each row... But for this column i don't really need key.
First problem : I can't use Order because Orders is ObservableCollection<Order>, why ?I can't use current row object ?Can i use Self or Current keywords ?Second problem :I would like to use an empty key...I didn't really need key in this case because i use parameter to call command actionHow remove this key ?
-----------------------------------------------------------------------------------------------------
I have another problem on column with multiple value;I'm trying to do this :
<ig:TemplateColumn Key="Person" HeaderText="Person" IsReadOnly="True" Width="100"> <ig:TemplateColumn.ItemTemplate> <DataTemplate> <TextBlock> <TextBlock.Text> <MultiBinding StringFormat="{}{0} {1}"> <Binding Path="Person.Name"/> <Binding Path="Person.FirstName"/> </MultiBinding> </TextBlock.Text> </TextBlock> </DataTemplate> </ig:TemplateColumn.ItemTemplate> </ig:TemplateColumn>
When i group the table on this column i get an exception.
Did i have to do converter to be able to sort or group this column ?
Can i create columns with multiple key ?
I find solution to this problem, i put Key="Person.Name" to repolace Key="Person".
Thanks
Hello Gred,
Thank you for your post.
I was researching your issue and you need to set an unique key for each column in the XamGrid. If you want you can use Unbound column and TemplateColumn with different keys and bind them to the same property of your underline data. Our XamGrid control does not allow us to define several columns with same key.
Would you please provide me with more details about what exactly you have in mind by ‘current row object’ and ‘Current keywords’ in order to be able to research the issue. I created a sample application(XamGridKey.zip) based on your scenario, to show you how you can implement the functionality that you want to achieve.
Please let me know if you need any further assistance on this matter.
In your sample there is the following code :
<ig:UnboundColumn Key="Order2" HeaderText="PDF"> <ig:UnboundColumn.ItemTemplate> <DataTemplate> <Button Style="{StaticResource EditButtonStyle}" BorderBrush="White" Background="White" Command="{Binding DataContext.Command2,RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ig:XamGrid}}}" CommandParameter="{Binding Order}"> </Button> </DataTemplate> </ig:UnboundColumn.ItemTemplate> </ig:UnboundColumn >
For me this parameter is null and didn't contain the order
I tried to add this :
<ig:UnboundColumn Key="Order3" HeaderText="Type"> <ig:UnboundColumn.ItemTemplate> <DataTemplate> <TextBox Text="{Binding Order.Order1}"/> </DataTemplate> </ig:UnboundColumn.ItemTemplate> </ig:UnboundColumn >
The TextBox is empty.
I tried 2 solutions to create Icommand :
First:
It works but i need to use the key ID in another <TextColumn>, so i can't do it like this
<ig:TemplateColumn Key="ID" HeaderText="Modif" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Width="50" IsSortable="False" IsFilterable="False" IsGroupable="False" IsGroupBy="False" IsReadOnly="True" > <ig:TemplateColumn.ItemTemplate> <DataTemplate> <Button Style="{StaticResource EditButtonStyle}" Height="18" Command="{Binding DataContext.OrderDetailCommand,RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ig:XamGrid}}}" CommandParameter="{Binding}"></Button> </DataTemplate> </ig:TemplateColumn.ItemTemplate> </ig:TemplateColumn>
Second :
I try to use UnboundColumn.
My function OrderDetailCommand need an parameter of Order's type.
The problem is when i used CommandParameter="{Binding}", the CommandParameter is type of Infragistics.Controls.Grids.UnboundColumnDataContext
I get the following Exception :Impossible to cast object type of 'Infragistics.Controls.Grids.UnboundColumnDataContext' in 'DataAccess.Order' type
I would like to use the CurrentRow of the XamGrid as parameter.
<ig:UnboundColumn.ItemTemplate> <DataTemplate> <Button Style="{StaticResource EditButtonStyle}" Height="18" Command="{Binding DataContext.OrderDetailCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ig:XamGrid}}}" CommandParameter="{Binding}" /> </DataTemplate> </ig:UnboundColumn.ItemTemplate> </ig:UnboundColumn>
I tried CommandParameter="{Binding Order}", the parameter is empty (null), i don't know why.
When i'm speaking of Current or Self i speak about the row.
For example i have collection of orders. The Xamgrid display each of them.
I would like to be able to get the object of type of order on each line and not only his property (Id,date, etc..).