I'm adding toolbar items to a toolbar at run-time. The toolbar items collection is being populated OK but the toolbar items are not displaying on the toolbar. If I include hard-coded toolbar items in my XAML they are diaplayed OK but any dynamically added ones are not. I've compared the attributes of the static items with the dynamic items but can't see what I'm missing - it's probably something simple. A snippet from my code-behind is below - this code is called after a collection of eGISToolBarItems to be added to the uxToolBar has been retrieved from a database repository. Any help would be much appreciated.
if (uxToolbar.Items == null)
{
uxToolbar.Items = new ToolbarItemCollection();
}
foreach (eGISToolBarItem item in toolBarItemData)
{
ToolbarItem tbi = new ToolbarItem();
Image img = new Image();
ImageSourceConverter isc = new ImageSourceConverter();
img.Source = (ImageSource)isc.ConvertFromString("Assets/Images/" + item.ImageFile);
ToolTipService.SetToolTip(img, item.ToolTip);
img.Stretch = Stretch.UniformToFill;
img.Margin = new Thickness(5);
img.VerticalAlignment = VerticalAlignment.Center;
img.HorizontalAlignment = HorizontalAlignment.Center;
tbi.Content = (FrameworkElement)img;
uxToolbar.Items.Add(tbi);
}