Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everybody!
I am trying to create a datagrid in wpf, which have row details is a other datagrid. I have done it. but now i want to process them.
Detail:
+ i want to select items in datagrid of detail when i click button. i could select items of datagrid parent.
+ In Rowheadtemplate i add togglebutton. I want to change color backgoround of togglebutton when value of one of the cell is "online"
So, i want to ask you. Can you help me?
Thank you so much. :)

What I have tried:

i catch select items of datagrid parent:
foreach (var item_dtg in dtg_ip.Items) // click icon-> row of dtg_IP
             {
                 if (((TextBlock)dtg_ip.Columns[0].GetCellContent(item_dtg)).Text.Trim() == imageTag.name)
                 {
                     dtg_ip.SelectedItem = item_dtg;
                     dtg_ip.ScrollIntoView(item_dtg);
                     break;
                 }
             }
Posted
Updated 14-Sep-16 17:56pm

1 solution

i have done a problem two:
+ In Rowheadtemplate i add togglebutton. I want to change color backgoround of togglebutton when value of one of the cell is "online":
C#
private void Button_Click_2(object sender, RoutedEventArgs e)
{
    for (int i = 0; i < dataGrid1.Items.Count; i++)
    { // Surat
        DataGridRow row = (DataGridRow)dataGrid1.ItemContainerGenerator.ContainerFromIndex(i);
        FrameworkElement tb = GetTemplateChildByName(row, "RowHeaderToggleButton");
        if (((TextBlock)dataGrid1.Columns[1].GetCellContent(dataGrid1.Items[i])).Text == "Online")
        {
            ToggleButton tgb = (ToggleButton)tb;
            tgb.Background = Brushes.Blue;
        }
    }
}

The first remaining issue.Can you have me a solution? thank you so much.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900