I'm creating from c# Data-grid that contain Data-Table and fill it with data,then I have refresh button that when i'm clicking it i want to see the cells that their value has been change in another color(red for example). I'm pretty new in WPF so I don't really understand how to do it from the XML and I'm creating the tables from the code so I try to do it from the code too. tried everything and the cell background is not changing.
Thank's for everyone that will try to help :)
example of the code for creating the DataTable:
string TID =selectedTab.Header.ToString().Split('~')[1];
List<Tuple<string,string>> FieldList = API.getFieldsByTableID(TID);
DataGrid dg = new DataGrid();
DataTable dt = new DataTable();
string[] TableLevel = splitTID(TID);
string TableDump = API.GetRegs(TableLevel[0], TableLevel[1]);
#endregion
#region *Fields_row*
foreach (var item in FieldList)
{
dc = new DataColumn(item.Item1, typeof(string));
dt.Columns.Add(dc);
}
#endregion
TableDump = TableDump.Split(':')[1];
int x = 0;
int DumpLen = TableDump.Length;
int EntrySize = int.Parse(API.GetEntrySize(TID));
int NumOfBytes = round_bits_2_chars_amount(EntrySize);
int count = 0;
while (x < DumpLen)
{
count++;
String str_Entry = BE_to_LE(TableDump.Substring(x, NumOfBytes));
ulong Entry = ulong.Parse(str_Entry, System.Globalization.NumberStyles.HexNumber);
DataRow dr = dt.NewRow();
int row = 0;
dr[row++] = count;
foreach (var item in FieldList)
{
int FieldLen = int.Parse(item.Item2);
ulong Mask =(ulong) ((1 << FieldLen) - 1);
ulong Value = Entry & Mask;
Entry = Entry >> FieldLen;
if (Properties.Settings.Default.IsHexadecimal)
{
dr[row] = "0x" + Value.ToString("X");
}
else
{
dr[row] =Value.ToString();
}
row += 1;
}
dt.Rows.Add(dr);
x += EntrySize;
}
dg.ItemsSource = new DataView(dt);
selectedTab.Content = dg;
}
}
XAML :
<Window x:Name="MainWindow1" x:Class="Nagasaki.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Nagasaki"
mc:Ignorable="d"
Title="Nagasaki" Height="464.839" Width="1021.708" WindowStartupLocation="CenterScreen" WindowStyle="ThreeDBorderWindow" ResizeMode="CanResizeWithGrip">
<Window.Resources>
</Window.Resources>
<Grid Margin="0,-3,3,5.6">
<TabControl x:Name="tabControl" Margin="0,5,0,-4.2" HorizontalAlignment="Left" Width="198" SelectedIndex="1">
<TabItem Header="FXP" Margin="99,-2,-148.2,0" FontFamily="Century Gothic" VerticalAlignment="Top" Height="17">
<ListBox x:Name="listBox" Margin="10,7,15.8,15.4"/>
</TabItem>
<TabItem Header="ETM" Margin="-49.8,-3,0,0" FontFamily="Century Gothic" Foreground="#FF060000" BorderThickness="0" VerticalAlignment="Top" Height="19" HorizontalAlignment="Left" Width="100">
<ListBox x:Name="ETM_listBox" Margin="7,10,7.8,11.4"/>
</TabItem>
</TabControl>
<Grid x:Name="GridButton" Margin="0,0,23,8.4" RenderTransformOrigin="0.5,0.5" MouseDown="GridButton_MouseDown" Width="29" HorizontalAlignment="Right" Height="25" VerticalAlignment="Bottom">
<Grid.Background>
<ImageBrush ImageSource="Red_Arrow_Head_Right-5121.png"/>
</Grid.Background>
</Grid>
<Button x:Name="button2" Content="Connect IA" Margin="0,0,71.6,7.8" Foreground="Black" BorderBrush="#FFB33434" BorderThickness="0" Click="button2_Click" Width="122" Height="25" HorizontalAlignment="Right" VerticalAlignment="Bottom" Background="#FFBDC3CA"/>
<Button x:Name="button" Content="Configuration" Margin="0,0,512.6,7.8" BorderThickness="0" Click="Configuration_Button_Click" RenderTransformOrigin="1.048,0.818" Height="25" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="122" Background="#FFBDC3CA"/>
<TabControl x:Name="DataTabControl" Margin="218,10,21.6,39.8" Background="#FFBCB3B3">
</TabControl>
<Button x:Name="CloseTabButton" Content="Close selected Tab" Margin="0,0,218.6,7.8" Background="#FFBDC3CA" BorderThickness="0" Click="button1_Click_1" Height="25" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="122" Foreground="Black"/>
<Button x:Name="CloseAllTabButton" Content="Close All Tabs" Margin="0,0,365.6,7.8" Background="#FFBDC3CA" BorderThickness="0" Height="25" Click="CloseAllTabButton_Click" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="122"/>
<Button x:Name="RefreshButton" Content="Refresh table" Margin="0,0,659.6,8.4" BorderThickness="0" Click="Refresh_Button_Click" RenderTransformOrigin="1.048,0.818" Height="25" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="122" Background="#FFBDC3CA"/>
</Grid>
</Window>
What I have tried:
searched in google and did not find answer for my problem.