HI
I have two questions; First is there a way to include a checkbox in the groupbyitemtemplate? I've got the the template working that includes the value and the count, but I am looking for a way to unselect the group so that the coorsponding display (points on a map) can be turned "off" Second question is if there is a way to set the groupbyitemtemplate for all columns or does it have to set for each column independantly?
Thanks for the help
Gregg
Hi Gregg,
I'm not really sure what you mean. If you want a checkbox in the GroupByRyow, you can use the GroupByItemTemplate. Can you provide more detail on where you want the checkbox to be, and what exactly you're attempting to accomplish?
As for your other question, we only provided that property on the Column level, not on the Grid or ColumnLayout level, so you would have to provide it for each column. However, you can define the DataTemplate in a ResourceDictionary, and use the same template on each column via a StaticResource.
-SteveZ
Hi Steve
Thanks for the reply. I've made a little headway but still have a ways to go. I'll see if I can clarify what I'm trying to do. I've gotten the checkbox to appear as I want using this template:
<igDataGrid:TextColumn Key="Event_Type" HeaderText="Category"> <igDataGrid:TextColumn.GroupByItemTemplate > <DataTemplate x:Name="GroupTemplate"> <StackPanel Orientation="Horizontal"> <CheckBox x:Name="GroupCheck" IsChecked="True"/> <TextBlock Text="{Binding Value}"></TextBlock> <TextBlock Text=" (" /> <TextBlock Text="{Binding Count}"></TextBlock> <TextBlock Text=")" /> </StackPanel> </DataTemplate> </igDataGrid:TextColumn.GroupByItemTemplate> </igDataGrid:TextColumn>
Now the next step is to hook up the checkbox "checked" event to an event handler. In the handler I want to loop through each of the rows in the group. In this case to turn off a point on a map. So I guess my current questions are:
1. How do I hook an event handler to the checkbox checked event in code? I'm not sure how to reference the checkbox to set the handler.
2. There are several columns in the grid that will have the same groupbyitemtemplate. Can I name all the checkboxes the same, in this case "GroupCheck" and use one event handler to deal with them all?
3. How do I reference (loop through) the group in the event handler?
Thanks and really appreciate you help.
Hey Gregg,
1. Just add the event handlers in xaml.
2. You can use the sender parameter of the event to get the checkbox. And thus you can use one event handler.
3. Just set the Tag of the CheckBox to identify it in the event. If you use one data template, you can simply just bind to the GroupByDataContext:
Now one thing to keep in mind, is that you'll want to make sure that you store whether the check box is checked somewhere, otherwise it will get lost due to virtualization. You can do this with a binding a ValueConverter on the IsChecked property.
<CheckBox Checked="CheckBox_Checked" Unchecked="CheckBox_Unchecked" IsChecked="{Binding Value, Converter={StaticResource mvc}}" Tag="{Binding}"></CheckBox>
<UserControl.Resources>
<local:MyValueConverter x:Key="mvc"/>
</UserControl.Resources>
MyValueConverter _mvc;
public Page2()
{
InitializeComponent();
this._mvc = this.Resources["mvc"] as MyValueConverter;
}
private void CheckBox_Checked(object sender, RoutedEventArgs e)
CheckBox cb = (CheckBox)sender;
GroupByDataContext gbdc = cb.Tag as GroupByDataContext;
if (gbdc != null)
this._mvc.UpdateValue(gbdc.Value, cb.IsChecked);
// Update Map
private void CheckBox_Unchecked(object sender, RoutedEventArgs e)
if(gbdc != null)
Hope this helps,
Just setting Tag="{Binding}" should do the trick.
Hope that helps,
One last question (I hope). How do I bind the GroupByDataContext to the tag? Can't quite seem to get the syntax right.
Thanks, Gregg
Thanks again for your help. I believe I have found the error of my ways and was able to use the data template to handle the event.
Thanks again, Gregg
There currently isn't an event that fires when a control is attached to GroupByCell.
Out of curiosity, why do you need to add the eventhandler in code, as opposed through the data template?
Again, thanks for the reply. I have a need to add in the event handler through code as opposed to XAML and I can't seem to figure it out. Here is the significant part of the XAML:
<igDataGrid:XamWebGrid x:Name="EventsGrid" Foreground="DarkBlue" FontSize="10" Background="WhiteSmoke" VerticalAlignment="Top" HorizontalAlignment="Left" Opacity="0.85" >
<igDataGrid:XamWebGrid.Columns>
<igDataGrid:TextColumn Key="event_id" HeaderText="Event ID"/> <igDataGrid:TextColumn Key="Event_Type" HeaderText="Category" x:Name="EventColumn"> <igDataGrid:TextColumn.GroupByItemTemplate > <DataTemplate x:Name="MyGroupTemplate"> <StackPanel Orientation="Horizontal"> <CheckBox x:Name="GroupCheck" IsChecked="True" /> <TextBlock Text="{Binding Value}"></TextBlock> <TextBlock Text=" (" /> <TextBlock Text="{Binding Count}"></TextBlock> <TextBlock Text=")" /> </StackPanel> </DataTemplate> </igDataGrid:TextColumn.GroupByItemTemplate> </igDataGrid:TextColumn>
</igDataGrid:XamWebGrid.Columns> </igDataGrid:XamWebGrid>
I need an addhandler statement like this one but I can't quite figure out how to reference the checkbox in the GroupByItemTemplate.
AddHandler DataWindow.EventsGrid.SelectedRowsCollectionChanged, AddressOf EventSelected
I appreciate the help. Gregg