StandaloneGallery.RefreshContextButtons(GalleryItem) Method
Redraws context buttons in the specified gallery item.
Namespace: DevExpress.XtraBars.Ribbon.Gallery
Assembly: DevExpress.XtraBars.v24.1.dll
NuGet Package: DevExpress.Win.Navigation
Declaration
Parameters
Name | Type | Description |
---|---|---|
item | GalleryItem | Gallery item for which to redraw context buttons. |
Remarks
The RefreshContextButtons method raises the GalleryControl.Gallery.ContextButtonCustomize event, and redraws context buttons in the specified gallery item.
The code below shows how to update a context button’s check state when a galery item’s check state changes, and vice versa. It is assumed that gallery items are associated with data items using the Tag property.
using DevExpress.Utils;
using DevExpress.XtraBars.Ribbon;
using DevExpress.XtraBars.Ribbon.Gallery;
galleryControl1.Gallery.ItemCheckedChanged += Gallery_ItemCheckedChanged;
galleryControl1.Gallery.ContextButtonCustomize += galleryControl1_Gallery_ContextButtonCustomize;
galleryControl1.Gallery.ContextButtonClick += galleryControl1_Gallery_ContextButtonClick;
private void Gallery_ItemCheckedChanged(object sender, GalleryItemEventArgs e) {
((DataItem)e.Item.Tag).IsChecked = e.Item.Checked;
(e.Gallery as GalleryControlGallery).RefreshContextButtons(e.Item);
}
private void galleryControl1_Gallery_ContextButtonClick(object sender, ContextItemClickEventArgs e) {
GalleryItem galleryItem = e.DataItem as GalleryItem;
galleryItem.Checked = !galleryItem.Checked;
}
private void galleryControl1_Gallery_ContextButtonCustomize(object sender, GalleryContextButtonCustomizeEventArgs e) {
CheckContextButton check = e.Item as CheckContextButton;
if (check == null) return;
DataItem data = (DataItem)e.GalleryItem.Tag;
check.Checked = data.IsChecked;
}
public class DataItem {
public bool IsChecked { get; set; }
}
See Also