Hi everybody,in my business application I'm using a ribbon bar and on more than one tab we need to have a date selection. I don't want to define it on every tab, instead I want to re-use the same definition.So, I've defined a ribbon resources:
<igRibbon:XamRibbon.Resources> <igRibbon:RibbonGroup Caption="{local:Translation Key=Common.Refresh}" x:Key="DateSelection"> <ig:LabelTool Caption="{local:Translation Key=Common.DateFrom}" /> <ig:XamDateTimeEditor MaxHeight="40" VerticalAlignment="Top" x:Name="dateFrom"/> <ig:LabelTool Caption="{local:Translation Key=Common.DateTo}" /> <ig:XamDateTimeEditor MaxHeight="40" VerticalAlignment="Top" x:Name="dateTo"/> <igRibbon:ButtonTool Caption="{local:Translation Key=Common.Refresh}" Click="DateSelection_Click"/> igRibbon:RibbonGroup>Now, I want to consume it, at least on two tabs. But how shell I do this?
<igRibbon:RibbonTabItem Header="{local:Translation Key=LblM.SerialHis}" Uid="SerialHis"> ??? igRibbon:RibbonTabItem>How I have to refered to the defined resources?Thanks in advance!
Hello Timon,
Thank you for your post.
Currently, when you populate the space between the opening and closing tabs of a RibbonTabItem, you are populating a RibbonGroupCollection object. The fact that you are populating a collection disallows the usage of your RibbonGroup as a resource here, but there is another way that you can reuse your RibbonGroup in this case. My recommendation to you would be to create your own custom class that derives from RibbonGroup and populate that RibbonGroup's Items collection in its constructor. Then, by creating a new "local" namespace, you can place your custom-created RibbonGroup between the opening and closing tags of your RibbonTabItem.
One issue that could pop up here is if you are looking to set the "Id" property of your RibbonGroup or the tools that exist inside it. Why this is an issue is because the XamRibbon will not allow tools or RibbonGroups to be added to it if those groups or tools have the same Id, and you will receive an exception if you try to do this. I am unsure if this is currently an issue for you, but I just thought I would make you aware of it. If it is indeed an issue for you, though, please let me know and I will see if I can workaround it in some way.
Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate DeveloperInfragistics Inc.www.infragistics.com/support
Hello Andrew,
I've tested it and it worked as I said before. But now I moved the class into a own shared dll and I've got two error messages:
But the SearchRibbonGroup inheriance from RibbonGroup as you'll find in my source code:
public class SearchRibbonGroup : RibbonGroup { public event RoutedEventHandler SearchStarted;
public string SearchText { get { return te.Text; } set { te.Text = value; } } public string EditorCaption { get { return te.Caption; } set { te.Caption = value; } } public string ButtonCaption { get { return b.Caption; } set { b.Caption = value; } }
private TextEditorTool te; private ButtonTool b; public SearchRibbonGroup() : base() { te = new TextEditorTool(); te.AcceptsReturn = false; te.AcceptsTab = false; te.KeyDown += te_KeyDown; AddChild(te); b = new ButtonTool(); b.Click += b_Click; AddChild(b); this.Closed += SearchRibbonGroup_Closed; } void SearchRibbonGroup_Closed(object sender, RoutedEventArgs e) { Closed -= SearchRibbonGroup_Closed; te.KeyDown -= te_KeyDown; b.Click -= b_Click; } void b_Click(object sender, System.Windows.RoutedEventArgs e) { if (SearchStarted != null) { SearchStarted(this, e); } } void te_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Tab || e.Key == Key.Enter) { b_Click(sender, new RoutedEventArgs(e.RoutedEvent)); } }
And I'm using it in that way:
<ig:RibbonTabItem Header="Common.Item"> <igView:SearchRibbonGroup Caption="Selection" ButtonCaption="Search" EditorCaption="ItemNo" SearchStarted="ItemSearch_Click" />
ig:RibbonTabItem>
What do I wrong?
What do I have to do to get rid of these error messages?
I can compile the whole solution - it is only a error in the WPF-Editor but it's getting anoying when I use the SearchRibbonGroup often at the same window.
Thanks again!
Edit: More detail infos
It seems very likely that this issue is being caused by the WPF-Editor in Visual Studio and not on our end. The reason that I have to believe this is because I have copied down the code that you have provided above into my own sample project, and I am unable to see the errors that you are currently seeing. My tests were made against Infragistics for WPF 2015.2 specific version 15.2.20152.2038 DLLs, and I have tested in Visual Studio 2013 and 2012 with no errors listed. If you are using some other environment settings from the ones I am using, please let me know.
It is possible that my sample project is not working in the way that you have yours working though, and so I have attached this sample project for your review. If there is something related to the "shared DLL" that you are using that doesn't exist in the sample project that I am sending you, would it be possible for you to please provide some more detail on what you are doing in your sample project?
it's getting worse.
I've removed all refs to the shared dll and removed the ribbon at all.
When I insert <igRibbon:XamRibbon /> to Xaml I'm receiving follow error in the WPF-Editor:
'Infragistics.Windows.Ribbon.RibbonBrushKeys.ButtonCheckedHottrackBorderFillKey' StaticExtension value cannot be resolved to an enumeration, static field, or static property.
Do you have any explanation for that?
I don't know what to do.
I am glad you were able to resolve this issue you were having. Also, thank you for adding what you had done to resolve this issue. I believe this may help other Infragistics community members in the future.
For everybody who will read this threat:
I've fixed it by myself: I ran the Upgrade Infragistics Assistent one more time over the whole solution. Afterwards it worked properly.
So, may be the versions weren't all the same. But the error message is very crazy.