开发者

Prism v4, MEF, WPF - Using proper Uri for module graphic

My solution's structure is:

Prism v4, MEF, WPF - Using proper Uri for module graphic

CI.Frontier.Classic contains a MEF module. My application uses the RibbonWindow control, and the modules define what menu items should be created. I can successfully add a button to the ribbon control from the CI.Frontier.Classic module, however, I cannot figure out the proper Uri to ClassicFrontierToopTip.png

Heres the code in FrontierClassic.cs that creates the tab, button and attempting to set the ribbon ToolTipImage

public void CreateMenuItems()
{
    TabData tabData = new TabData("L开发者_高级运维egacy");

    GroupData groupData = new GroupData("Internal");
    tabData.GroupDataCollection.Add(groupData);

    ButtonData classicFrontierBtn = new ButtonData()
    {
        Label = "Classic Frontier",
        ToolTipTitle = "Classic Frontier",
        ToolTipDescription = "Open Classic Frontier",
        ToolTipImage = new Uri("./Graphics/ClassicFrontierToolTip.png", UriKind.Relative)
    };
    classicFrontierBtn.Command.RegisterCommand(new DelegateCommand(LoadFrontierView));


    groupData.ControlDataCollection.Add(classicFrontierBtn);

    _ribbonService.AddTab(tabData);
}

This Uri doesn't work as the tooltip does not display. Can I use the UriKind.Relative or should I be using some sort of "pack uri"?


The robust approach would be to leverage the pack syntax...

new Uri("pack://application:,,,/CI.Frontier.Classic;component/Graphics/ClassicFrontierToolTip.png", UriKind.Absolute);


Include an icon for a Prism module solved it...

ToolTipImage = new Uri("/" + GetType().Assembly.ToString().Split(',')[0] + ";component/Graphics/ClassicFrontierToolTip.png", UriKind.Relative)

Not sure if this is the best solution though.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜