Hello,
The current version of XAF does not allow you to set up tooltips for the editors. For now, you may only set the tooltips for edtors at runtime. You should create a new ViewController, access the required PropertyEditors, obtain the actual editors and setup their tooltips property values:
public class SetToolTipsViewController : ViewController {
public SetToolTipsViewController()
: base() {
this.TargetViewType = DevExpress.ExpressApp.ViewType.DetailView;
}
protected override void OnActivated() {
this.View.ControlsCreated += new EventHandler(View_ControlsCreated);
}
protected override void OnDeactivating() {
this.View.ControlsCreated -= new EventHandler(View_ControlsCreated);
}
void View_ControlsCreated(object sender, EventArgs e) {
DetailView view = (DetailView)View;
for(int i = 0;i < view.Items.Length;i++)
((BaseEdit)view.Items[i].Control).ToolTip = view.Items[i].Caption;
}
}
Thanks,
Dan
How to display a tooltip/hint for an editor, its caption/column header, and other elements
Answers
Starting with v12.2, you can specify a new ToolTip property at the Class member (IModelMember), ListView column (IModelColumn), DetailView item, navigation & layout group (IModelLayoutGroup ) and item levels in the application model. Note that once set for a class member, the tooltip value is automatically calculated for below layers such as ListView column, DetailView item, layout group and item, unless the user has already set a tooltip at these levels.
For more convenience, you can use the new ToolTipAttribute to set tooltip options in the code of your business class.
Take special note that additional tooltip settings such as ToolTipTitle and ToolTipIconType have effect for WinForms applications in DetailView only.
Note: At the moment, tooltips with rich content (e.g., HTML formatting) are NOT supported when using the aforementioned ToolTipAttribute and ToolTipXXX features (they provide simple text hints only). If you require more advanced tooltips, you can implement different custom-tailored solutions for different platforms:
WinForms:
WinForms Controls > DevExpress.XtraEditors > WindowsFormsSettings > DefaultAllowHtmlDraw
WinForms Controls > Common Features > HTML Text Formatting
WinForms Controls > DevExpress.Utils > ToolTipController
ASP.NET WebForms:
You can integrate our DevExpress.Web > ASPxHint component as described in the ASPxHint - How to set custom content article or demos.
However, nothing prevents you from using standard ASP.NET or JavaScript means (e.g., JQuery - see an example here) to implement custom-tailored solutions with the desired behavior. From our controls, the ASPxPopupControl seems to be most suitable. It can be used to emulate tooltips. Please review the following demos: one, two, three. Do not hesitate to contact our ASP.NET team on this in case of any questions.
@Willem: Thank you for describing your use-case scenario. We will take it into account.
Currently, you can use capabilities of the ToolTipController to implement this task in a ListView. Please refer to the Show tooltip with property value ticket for some example code.
@Dennis: Thank you for referring the mentioned ticket. Somehow it didn't show up when i searched for 'tooltip'. The code is quite elaborate over there, so i'd like to vote for extending the functionality of the tooltipattribute! :)
@Willem: Thanks for your feedback. We will take it into account. Let us know if you experience real difficulties when you have an opportunity to implement and maintain this solution in your project.
Hi everyone,
I just wanted to know what the XAF community thinks about displaying tooltips for editors and their captions:
UPDATE:
The information below is now outdated. Refer to the answer below for more details.
For now, I think about introducing an enumeration that will allow a developer to control this behavior on the application level (Options | ToolTipsDisplayMode):
public enum ToolTipsDisplayMode { None, CaptionAndEditor, Caption, Editor }
Please let us know your opinion in comments by posting the option number that you like most.
3.) !
and an enum as option is very flexible!
well, all users are known to use tooltips in the editor in other applications. only in caption is not enough.
Am I right in thinking that Boolean editors (CheckEdit) hides the layout caption and use the editor text ? This would steer the answer to 2 or 3.
Also within an editor it should be overrideable in the property editor - in case you've added e.g. an Ellipse button which does a post code lookup. I think this is probably currently ok and doable.
I'm leaning toward an IModelOptions level setting which chooses between 2 or 3 - if my observation re. bools is correct above.
Also nice to have would be a property level attribute to seed the tooltip.
3 seems best. Could this also be surfaced on fields list such as reports field explorer and filter editor?
>Also nice to have would be a property level attribute to seed the tooltip.
+1
Thank you for the feedback, guys.
You will be able to set a tooltip for a property as follows:
[DomainComponent] public class ToolTipTester { [ModelDefault("ToolTip", "Test for {0}")] public string Name { get; set; } }
Why the aversion to using a concrete attribute Dennis ?
There are a number of tooltip related properties that might be requested in the future e.g. ToolTipTitle, IsBalloon - e.g. see http://www.c-sharpcorner.com/uploadfile/mahesh/tooltip-in-C-Sharp/
Dennis, as a side note, I know about ModelDefaultAttribute which has supersceded the CustomAttribute (which we were generally discouraged from using). I think that typed attributes are more useful as:
- they're easier to extend property wise,
- they don't rely on model knowledge - that's an implementation detail,
- they're easier to search for,
- they place an onus on DX to document etc.
Enumeration is the best, otherwise I prefer 3.
Please let me assure that tooltips set via attributes will be localizable.
And if I can make things up - is it possible to introduce tooltips for tabs on forms - win as well as web :-)
Thank you Dennis
This is nice!!! My pref is 3.
I like Jascha's question as well. It would be very handy!!! "Could this also be surfaced on fields list such as reports field explorer and filter editor?"
@Carlitos & @Jascha: +1!!!
3 would be good for me.
I hope it gets extended attributes to include BO (and not only properties) to allow for a global hint for a detail view.
This makes me wonder if it would be even better to be able to override what has been generated by attributes to make specific hints for some views right in model editor.
Thanks Dennis for your efforts
ditto on #3…
@Mohsen:
>>
I hope it gets extended attributes to include BO (and not only properties) to allow for a global hint for a detail view.
<<
How and where it should be shown in the UI? I suppose that you are talking about tooltips for respective navigation items, right?
#3 is ok for me. I have already asked for this feature before. Thanks for attention.
>> I hope it gets extended attributes to include BO (and not only properties) to allow for a global hint for a detail view.
> How and where it should be shown in the UI? I suppose that you are talking about tooltips for respective navigation items, right?
Not only for nav items. It should also be possibel to show these tooltips on tabs when tabbed MDI is used.
I vote for #3.
Plus report fields explorer, filter editor, Analysis and Pivotgrid.
@Dennis: I am currenty using my own little controller for this. After I had used it a for a while, I soon saw the necessity to implement the tooltips on the view and view columns too, to override the tooltips on the BO and member level.
The UI is view oriented after all, therefore tooltips defined at the view level should have higher priority than those defined at the BO level. Only when a tooltip at view level is null (which is the default), the tooltip from BO level is used.
Thus I can override a tooltip in each and every view, when I want so, and also suppress it by entering an empty string in the model editor. JM2€C.
>>
After I had used it a for a while, I soon saw the necessity to implement the tooltips on the view and view columns too, to override the tooltips on the BO and member level.
The UI is view oriented after all, therefore tooltips defined at the view level should have higher priority than those defined at the BO level. Only when a tooltip at view level is null (which is the default), the tooltip from BO level is used.
<<
Sure…this is the default behavior for all standard properties like Caption, DisplayFormat, etc.
Ok, when watching your video I had the impression that you plan to implement this on the BO member level only.
12.2?
12.2??
@Chris: I have added a new ToolTipAttribute as you suggested. Thank you for your persistence.
Hi Dennis, thanks for implementing such a useful ToolTipAttribute for properties. Will it be available in v12.1.8?
@James: The stuff I discussed above will be available in 12.2 only.
Thanks Dennis for your information! I'll try this new feature after two months :)
@Dennis - thanks :)