First
of all, this piece of information is quite advanced, so be sure you are
well-aware of the module's basic functions and main extensibility and
customization points, at least through AppearanceController. If not, check
out the related online documentation before reading further.
Customer scenario
Would it be possible to add in the conditional appearance module the possibility to show a tooltip in the cell in listView when the
condition is satisfied? (you get different color based on criteria and when you move to the cell a tooltip is shown telling you why the color is different ), example:
[C#]
[Appearance("CategoryColoredInListView", AppearanceItemType = "ViewItem",
TargetItems = "Category", Criteria = "Category = 'Seafood'", Context = "ListView",
FontColor = "Blue", Priority = 1, ToolTip="the tooltiptext!!!!"
)]
Alternative solution considerations
If there were no ready built-in module in XAF, you could solve this by using the pure means available for the underlying grid control for a target platform. For instance, in WinForms, you could employ the ToolTipController API, while for ASP.NET WebForms you could handle the ASPxGridView events to programmatically assign a tooltip text to required data cells. Apparently, making these custom-tailored control-based solutions universal would require effort without XAF, and XAF users could even see this work as a duplication of the perfect existent infrastructure ConditionalAppearance provides. So, let's describe how to do things the XAF way!XAF way
Let me repost the answer my colleague provided in the original SC ticket and then elaborate more on the technical aspects of this solution:
Technical details
Solution26.Module:
AppearanceWithToolTipAttribute.cs - contains a definition
of an AppearanceAttribute descendant with a custom ToolTip property (its sample
use is shown in the Class1.cs file) as well as several required service classes
to propagate this new option through the Application Model and the whole
ConditionalAppearance module infrastructure. For instance,
the AppearanceItemToolTip class is an AppearanceItemBase descendant that
serves the same role as AppearanceItemEnabled, AppearanceItemFontColor and
other built-in implementations (here it solely holds a tooltip value).
The IModelAppearanceWithToolTipRule interface and its domain logic define a custom Application Model element that extends the built-in IModelAppearanceRule with the ToolTip property (see the Module.cs file for the registration code).
Finally, the ToolTipAppearanceRule class is a
descendant of the service AppearanceRule class with a single overridden method
that instantiates AppearanceItemToolTip objects for
IModelAppearanceWithToolTipRule nodes defined by a user in the Application
Model.
Solution26.Module.Web:
AppearanceGridViewToolTipController.cs - contains a
ViewController that handles the CustomCreateAppearanceRule and
ApperanceApplied events of the built-in AppearanceController for connecting
rule metadata information with the underlying control customizations. In other
words, the information from the AppearanceItemToolTip entity is
propagated to the built-in TableCellAppearanceAdapter object, which represents
a precise implementation of the IAppearanceFormat interface (there are various
implementations for different UI entities in XAF). Or, simply, a link between
the underlying UI control and its TableCell object to which various appearance
options (font, color, tooltip) can be applied.
Hello Dennis, nice feature. I tested it and it works fine in your example.
ReplyDeleteBut when I create an appearance rule without setting the backcolor, the tooltip does not work. So the tooltip only works when also using the existing properties like back and fore color.
Can you edit your example and make it possible to create and use an appearance rule with only the tooltip filled?
Hi Hein, yes, I can replicate this behavior. I will post here once I have a chance to debug this case.
DeleteGreat, thank you!
DeleteHello Dennis, any progress on this issue?
DeleteHi. I need union all ToolTips from all applied [AppearanceWithToolTip] by Priority values order
ReplyDeleteFor code
[DefaultClassOptions]
public class MyPerson : BaseObject {
public MyPerson(Session session) : base(session) { }
[AppearanceWithToolTip("MinorAppearance", "[Important] = false", BackColor = "Green", ToolTip = "Minor", Priority = 0)]
[AppearanceWithToolTip("MinorAppearance2", "[Important] = false", FontStyle = FontStyle.Italic, ToolTip = "Addition tooltip", Priority = 1)]
public string Name { get { return GetPropertyValue("Name"); } set { SetPropertyValue("Name", value); } }
public bool Important { get { return GetPropertyValue("Important"); } set { SetPropertyValue("Important", value); } }
}
I want see
"Minor
Addition tooltip"
And i need solution for Win