I am adding a row to a hierarchical gridview programatically. The row is in the child gridview of the selected row. I am able to add the row using the underlying data, but if the parent row is not expanded, one cannot immediately see the new row, so I want to automatically expand the parent row when the new row is added. All of the events that I have been able to trap do not seem to have access to the RadRowItem so I can expand the parent row. They all seem to have access to the underlying data but not the ui element. Also, since I am using the Click event to add the row instead of the ICommand beginInsertRow, the AddingRow event does not seem to fire. Please let me know how I can achieve the result that I need. Thanks,
Carl
snippet that adds the row:
private
void insertOption_Click(object sender, RoutedEventArgs e)
{
var expandCommand = RadGridViewCommands.ExpandHierarchyItem as RoutedUICommand;
if (selectedItem == null)
{
return;
}
if (selectedItem.GetType() == typeof(RadGridView))
{
var rgv = (RadGridView)selectedItem;
if (rgv != null)
{
Object o = rgv.SelectedItem;
if (o != null)
{
// check if optionssheet style,option,bom, or component
if (o.GetType() == typeof(OptionsSheet))
{
addStyle(o);
}
else if (o.GetType() == typeof(RadControlsSilverlightApp5.com.tradestonesoftware.optionssheet.model.Style))
{
addOption(o);
}
else if (o.GetType() == typeof(Option))
{
addBom(o);
}
else if (o.GetType() == typeof(Bom))
{
addComponent(o);
}
}
}
}
}
private void addBom(object o)
{
Option option = (Option) o;
option.boms.Add(
new Bom());
}
private void addOption(object o)
{
RadControlsSilverlightApp5.com.tradestonesoftware.optionssheet.model.
Style style=(RadControlsSilverlightApp5.com.tradestonesoftware.optionssheet.model.Style)o;
style.options.Add(
new Option());
}
private void addStyle(object o)
{
OptionsSheet sheet = (OptionsSheet)o;
sheet.styles.Add(
new RadControlsSilverlightApp5.com.tradestonesoftware.optionssheet.model.Style());
}