Using C#.NET4.5, Visual Studio 2012, WPF.
Well here's how far I got with a lot of help from great people and advice!
Set up a new column for images:
DataGridTemplateColumn p1 = new DataGridTemplateColumn();
p1.Header = "p1";
FrameworkElementFactory factory1 = new FrameworkElementFactory(typeof(System.Windows.Controls.Image));
Binding b1 = new Binding("picture");
b1.Mode = BindingMode.TwoWay;
factory1.SetValue(System.Windows.Controls.Image.SourceProperty, b1);
DataTemplate cellTemplate1 = new DataTemplate();
cellTemplate1.VisualTree = factory1;
p1.CellTemplate = cellTemplate1;
paretogrid.Columns.Add(p1);
Then I check each "row" and set up some Ifs to check values:
private void ShowArrows()
{
var rows = GetDataGridRow(paretogrid);
foreach (DataGridRow r in rows)
{
DataRowView rv = (DataRowView)r.Item;
var par3 = paretogrid.Columns[7].GetCellContent(paretogrid.Items[2]) as TextBlock;
int pconv3 = Convert.ToInt32(par3.Text);
var par2 = paretogrid.Columns[8].GetCellContent(paretogrid.Items[2]) as TextBlock;
int pconv2 = Convert.ToInt32(par2.Text);
var par1 = paretogrid.Columns[9].GetCellContent(paretogrid.Items[2]) as TextBlock;
int pconv1 = Convert.ToInt32(par1.Text);
var parNew = paretogrid.Columns[10].GetCellContent(paretogrid.Items[2]) as TextBlock;
int pconvNew = Convert.ToInt32(parNew.Text);
if(pconv3 == pconv2)
{
paretogrid.Columns[12].
}else
if(pconv3 > pconv2)
{
//uparrow
}
else
if (pconv3 < pconv2)
{
//down
}
}
}
So as you can see I step through, throw it into a few nested conditions then where the comments are is where I want to add the images, something like :
paretogrid.columns[12].setvalue(can image go here? asks for dependency);
not sure how to add the image all I see is adding images to an entire column via the item source.
Where am I going wrong?
EDIT: 08/04/2013 Ok got two suggestions, so far no errors are happening which is always nice to me. unfortunatly no images are showing up.
Datagrid.Children.Add();
for some reason my datagrid does not have this .Children method in the intellisense, even when I force it it just redlines me. What am I missing?
Not big on XAML so heres the grid.
Grid Margin="10,13,6,-13" Background="{DynamicResource {x:Static SystemColors.ActiveCaptionTextBrushKey}}" HorizontalAlignment="Left" Width="1442">
<DataGrid Name ="paretogrid" HorizontalAlignment="Left" Height="500" Margin="16,63,0,0" VerticalAlignment="Top" Width="1126" RenderTransformOrigin="0.5,0.5" Background="{x:Null}" FontSize="14" SelectionChanged="paretogrid_SelectionChanged">