Is there a way to prevent template column contents from appearing in the new row? In the screen shot you can see that the red delete icon is appearing in the new row. I wish to hide this in the new row.
Regards
Myles Johnson
I have the exact same issue. Did you ever get a resolution to your question? I'm using SL4 and Infragistics 2010.2
Regards,
Robert
You would have to be careful with simply setting the Visibility in this manner due to the virtualization done by the XamWebGrid to enhance performance. If your row is wider then then the grid, and your template column is scrolled off, those cells would be recycled. Since the XamWebGrid doesn't know that you just hid a the cell control, it can assign that cellcontrol to any valid target. Which means any cell in that template column could now get a cell control attached to it that already has it's visibility turned off.
On a side note, we will be some Template properties to TemplateColumn to allow for a different template to be applied for Filter and AddNewRow.
Seems like overkill when you could simply write the following one liner:
RowsManager.AddNewRowTop.Cells["Delete"].Control.Visibility = Visibility.Collapsed;
This can be done with a value converter hooked up to the Visibility property of the button in your template.
Below is some sample code showing how to create a simple value converter and how to hook it up to the Button in the template.
<UserControl x:Class="SilverlightApplication16.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:SilverlightApplication16"
xmlns:iggrid="clr-namespace:Infragistics.Silverlight.Controls;assembly=Infragistics.Silverlight.XamWebGrid.v9.2"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">
<Grid x:Name="LayoutRoot">
<Grid.Resources>
<local:MyValueConverter x:Key="myConvert"></local:MyValueConverter>
</Grid.Resources>
<iggrid:XamWebGrid x:Name="grid">
<iggrid:XamWebGrid.AddNewRowSettings>
<iggrid:AddNewRowSettings AllowAddNewRow="Top"></iggrid:AddNewRowSettings>
</iggrid:XamWebGrid.AddNewRowSettings>
<iggrid:XamWebGrid.Columns>
<iggrid:TemplateColumn Key="blah">
<iggrid:TemplateColumn.ItemTemplate>
<DataTemplate>
<Button Content="Delete" Visibility="{Binding Converter={StaticResource myConvert}}" ></Button>
</DataTemplate>
</iggrid:TemplateColumn.ItemTemplate>
</iggrid:TemplateColumn>
</iggrid:XamWebGrid.Columns>
</iggrid:XamWebGrid>
</Grid>
</UserControl>
public class MyValueConverter : IValueConverter
{
#region IValueConverter Members
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
Person p = value as Person;
if (p == null || p.Name == null)
return Visibility.Collapsed;
}
return Visibility.Visible;
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
throw new NotImplementedException();
#endregion