Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
910
Change Image of PopupMenuTool in runtime
posted

Hi,

we want to be able to change the image of a popupmenutool at runtime:

switch (e.Tool.Key)
{
case "ButtonTool2":

PopupMenuTool popupMenuToolCaptionAlignmentVertical = ultraToolbarsManager1.Tools["PopupMenuTool1"] as PopupMenuTool;
if (popupMenuToolCaptionAlignmentVertical != null)
{
//AppearanceData appearanceData = new AppearanceData();
//popupMenuToolCaptionAlignmentVertical.Tools[0].ResolveAppearance(ref appearanceData);

if (popupMenuToolCaptionAlignmentVertical.CustomizedImage != null)
{
popupMenuToolCaptionAlignmentVertical.CustomizedImage.Dispose();
popupMenuToolCaptionAlignmentVertical.CustomizedImage = null;
}

popupMenuToolCaptionAlignmentVertical.CustomizedImage = Image.FromFile(...);

}

While changing of a PopupColorPickerTool works, the icon of the PopupMenutTool is not changing.

Michael

  • 48586
    Verified Answer
    posted

    Hello ,

     

    Appearance of ToolObjects are resolved by the following hierarchy

    1. Get SharedProps , get AppearanceSmall is state of the tool is  small

    2. If the state is Large the appearance will try to get everything from AppearanceLarge and if there is any defaults which could be populate by AppearanceSmall they will be got.

    3. If there is InstanceProps, then appearance from instance props get precedence over SharedProps from SharedProps

    4. Again any defaults will be filled by the appearance with lower priority (i.e. from SharedProps - > SharedProps then SharedProps-> AppearanceSmall)

     

    So I am not sure which exactly version you are using, but setting your image on SharedPropsAppearance should works. You should change your code to something like:

    popupMenuToolCaptionAlignmentVertical.SharedProps.AppearancesSmall.Appearance.Image = Image.FromFile("..\\..\\Folder.jpg");

     

    Please let me know if you have any further questions.