
I sorry to bother you again, I'm still searching :-(
I think the XAML is OK now! Here it is:
<ribbon:Group Label="Images" KeyTipAccessText="ZI">
<ribbon:Group.Variants>
<ribbon:GroupVariant Priority="20" Size="Medium" />
<ribbon:GroupVariant Priority="60" Size="Small" />
<ribbon:GroupVariant Priority="70" Size="Collapsed" />
</ribbon:Group.Variants>
<ribbon:RibbonGallery x:Name="RG" Label="Images" ItemsSource="{Binding}" Width="200" KeyTipAccessText="L" IsSelectionHighlightVisible="True">
<ribbon:RibbonGallery.ItemTemplate>
<DataTemplate>
<Image Margin="2" Width="80" Height="60" Source="{Binding BindsDirectlyToSource=True}" Stretch="UniformToFill" />
</DataTemplate>
</ribbon:RibbonGallery.ItemTemplate>
<ribbon:RibbonGallery.PopupContent>
<StackPanel>
<ribbon:PopupGallery IsSelectionHighlightVisible="True" Name="RGPG" ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ribbon:RibbonGallery}}, Path=ItemsSource}">
<ribbon:PopupGallery.ItemTemplate>
<DataTemplate>
<Image Margin="2" Width="80" Height="60" Source="{Binding BindsDirectlyToSource=True}" Stretch="UniformToFill" />
</DataTemplate>
</ribbon:PopupGallery.ItemTemplate>
</ribbon:PopupGallery>
</StackPanel>
</ribbon:RibbonGallery.PopupContent>
</ribbon:RibbonGallery>
</ribbon:Group>
Here is the C#:
void FillImagesControls(int i)
{
if (i == 0)
{
return;
}
ClearFields();
TreeViewItem tvi = new TreeViewItem();
tvi = (TreeViewItem)tvMenu.SelectedItem;
TreeViewItem parent = (TreeViewItem)tvi.Parent;
if ((string)parent.Header == "Bonsai's")
{
taImages.FillByBonsaiID(dtImages, i);
foreach (dsTMB.tblImagesRow row in dtImages)
{
MemoryStream s = new MemoryStream(row.ImageBinary);
MemoryStream slarge = new MemoryStream(row.ImageBinary);
System.Windows.Media.Imaging.BitmapImage img = new System.Windows.Media.Imaging.BitmapImage();
System.Windows.Media.Imaging.BitmapImage imglarge = new System.Windows.Media.Imaging.BitmapImage();
img.BeginInit();
img.StreamSource = s;
img.EndInit();
imglarge.BeginInit();
imglarge.StreamSource = slarge;
imglarge.EndInit();
alimageslarge.Add(imglarge);
alimages.Add(img);
RG.ScreenTipDescription = row.ImageName;
}
}
else if ((string)parent.Header == "Potten")
{
taImages.FillByPotID(dtImages, i);
foreach (dsTMB.tblImagesRow row in dtImages)
{
}
}
RG.ItemsSource = alimages;
RG.DataContext = alimages;
RGPG.ItemsSource = alimages;
RGPG.DataContext = alimages;
}
I've got some questions now.
The base is that the code gives one image in the ribongallery while there are two. Why
would that be?
The popup gives two so that is OK!
I load the images when a menu is clicked this works ok. But when I navigate away the images don't dissapear. I should remove the items but the control is in use. How can I do that?
When a other item in the menu is clicked the gallery should show other images. How can solve this?
Could you please give me answers with code. I'm very visual in this and tired of searching..
Roel