OK... I have kindof a sepecialised case. I am getting log data back from a DB that has 5 static properties and then any number of variable properties. The class looks like this:
Prop 1, prop 2, prop 3, collection of properties 4-n... all possible properties are known.
Based on the type of log, properties 4-n will be different, again, all possible properties will be known.
The values of these properties will always be text.
binding properties 1-3 are easy... but is it possible to bind column values to items within a sub collection? for example, key="{Binding PropCollection.Prop4}"
Thanks in advance for any help
Marc
Hi Ted,
Sorry for the delayed response.
I should have mentioned this earlier. The UnboundColumn has a different DataContext than a TemplateColumn. We did this, so that users have access to more information, and also so they don't have to duplicate their work.
So the DataContext is of type: UnboundColumnDataContext, which as 3 members that you can bind to:
RowData, Value, and ColumnKey.
RowData - represents the data object for the current row.
ColumnKey - is simply the key that you assigned to the column
Value - is what your ValueConverter returns.
So, in the DataTemplate you listed above you should use {Binding Value}
Hope this helps,
-SteveZ
A question and a suggestion:
Question: Is there a reason you cannot use the built in ImageColumn for this?
Suggestion: Image URL's in Silverlight are a bit of a pain in the a**. Where I usually start in debuggin this is attaching the ImageFailed event to the Image control. This will tell me if its something like a network failure (which usually means my URL is wrong).
Devin
Should the following scenerio work with a Unbound Column:
I am trying to render a Image in a column based on the Url in the dictionary. the converter runs and returns the correct BitMapImage, but it does not display in the grid. if i change the image width and height in my custom datatemplate the grid expands so i think the itemtemplate is working correctly
Set the datatemplate of the column to:
<
DataTemplate x:Key="iconPresenterStyle">
Image Stretch="Fill" Width="40" Height="40" Source="{Binding}" />
</
DataTemplate>
Code is here:
if
(IsIcon)
{
ItemTemplate =
Application.Current.Resources["iconPresenterStyle"] as DataTemplate;
// Gets absolute url based on location of .xap download
converter =
new Hyland.Types.Silverlight.Converters.IconUriConverter();
ValueConverterParameter =
Convert.ToString(columnElement["name"]);
}
Converter is here:
PropertyBag
bag = value as PropertyBag;
string index = parameter as string;
Uri uri = null;
if (null != bag && !string.IsNullOrEmpty(index))
if (bag.Contains(index))
// ../ assumes the Xap package is in a clientbin folder below the root
uri =
new Uri(Application.Current.Host.Source, "../" + bag[index]);
// return image from onbase web server or an empty image if no
// url found in element
if (null != uri)
return new BitmapImage(uri);
else
return new BitmapImage();
I was able to reproduce what I believe is the issue you are reporting with regular bound columns. I will record the issue I can reproduce.
I tried it with unbound columns and it failed in the same place, so I will assume it is the same issue.
Ted Ogrean said: Drag Column 3 to Group by by area, Expand first row in list, drag column 4 to group by area. Then drag Column 3 from the group by area back onto the grid. I get the above "object not set to instance" error every time.
Drag Column 3 to Group by by area, Expand first row in list, drag column 4 to group by area.
Then drag Column 3 from the group by area back onto the grid. I get the above "object not set to instance" error every time.
Thank you for your report.
I can consistently make the grid crash using the Unbound columns only (about 10 of them) with teh following steps:
Then drag Column 3 from the group by area back onto the grid. I get the above "object not set to instance" error every time. I will continue to test.