Hello,
I have a cross-platform XAF application that is producing incorrect horizontal alignment of two labels on one detail view. Please see attached screen image. This is not happening on other controls nor other views, web or win versions.
Note that a particularity of this application is that the words "Job", "Drawing", and "Stockbill" are encoded in the captions using meta-syntax like
[ModelDefault("Caption", "{JobItemName,s,t} Test")]
Caption parsing and replacement is performed in the platform-agnostic Module.cs handler for Application.LoggedOn. The image shows that this parsing works correctly for other captions. I added 'Test' to the first caption to see if the presence of text after the meta-syntax was the issue, but the caption remains left-justified. If I completely disable the substitution the issue remains. If I change the caption for this property to have only normal text the issue remains.
When I examine the CSS of the detail view I see that the correctly-aligned labels have classes "Caption haRight vaTop" defined, but the problematic ones have "Caption " (with two trailing spaces). Other than this the markup looks correct and 'clean'. I can find no web application model overrides that might affect the alignment.
Is there a web equivalent of Model.User.xafml that retains model changes?
Can you suggest what might cause this, or where I can look for the source of the problem?
Thank you,
Mark
Hello Mark,
>>Is there a web equivalent of Model.User.xafml that retains model changes?
No, by default, the changes are stored either in cookies or in the database.
>>Can you suggest what might cause this, or where I can look for the source of the problem?
While we cannot suggest this judging by a screenshot, we will be more than happy to debug a small problematic sample showing this behavior and help you find a suitable solution.
Dennis,
Dennis,
I believe this problem is due to a bug. Here's what I did:
First I traced into DevExpress.ExpressApp\DevExpress.ExpressApp.Web\Layout\LayoutItemTemplate.cs, stopping here:
switch(layoutItemTemplateContainer.CaptionHorizontalAlignment) {
case DevExpress.Utils.HorzAlignment.Far:
horizontalAlignmentClass = layoutItemTemplateContainer.CaptionLocation == DevExpress.Utils.Locations.Right ? "haLeft" : "haRight";
break;
case DevExpress.Utils.HorzAlignment.Center:
horizontalAlignmentClass = "haCenter";
break;
case DevExpress.Utils.HorzAlignment.Near:
horizontalAlignmentClass = layoutItemTemplateContainer.CaptionLocation == DevExpress.Utils.Locations.Right ? "haRight" : "haLeft";
break;
}
I noticed that for the problematic controls the value of CaptionHorizontalAlignment was Default, so the switch was skipped, and the CSS class haRight was not included.
I then searched for the source of the Default setting and found that the Solution.Module application model DetailView for the underlying class contained an override of the value for CaptionHorizontalAlignment for these two properties. Rather than having the default value Far, it had been set to the value Default. Three other attributes were also overridden with the value Default (CaptionVerticalAlignment, CaptionWordWrap, and SizeConstraintsType). Refer to the first image in the attachment.
Once I reset these values to their true defaults (Far, Top, Wrap, and Default, see second image in attachment), the problem disappeared (see third image in attachment).
These values were not overridden by me, but by the detail view Customize Layout feature. I have often seen this happen during normal, simple manipulations of detail views, over many versions of DevExpress. I have also often reset the values because the spurious overrides annoy me, but I never saw any problems arise from this. This was perhaps because I have been doing only Windows application development. I am now doing a cross-platform application and see this problem, but only in the web version of the detail view.
I look forward to your thoughts about this.
Thank you,
Mark
Hello Mark.
I have tried to replicate this issue on my side, but to no avail. The CaptionHorizontalAlignment, CaptionVerticalAlignment, CaptionLocation, and CaptionWordWrap properties are set to "Default" by default and resolved to the same values for all labels. I recommend that you verify the following:
>>>These values were not overridden by me, but by the detail view Customize Layout feature. I have often seen this happen during normal, simple manipulations of detail views, over many versions of DevExpress. I have also often reset the values because the spurious overrides annoy me, but I never saw any problems arise from this.
<<<
AFAIK, we don't have code that automatically customizes the model in this manner. To research what causes this glitch, we need a sample project and detailed instruction on how to replicate it.
Michael,
I have reproduced the problem but not reliably. However, I can reliably reproduce a similar problem. Start with any new XAF project, Win-only is fine, create a business class, and then:
This last behavior is also innocuous when it happens to an Empty Space Item, but I just saw it happen to a form node with a non-null ViewItem, just as I described in my initial post.
I executed this Unix command on a medium-sized XAF Win-only application that's been in production for six months:
grep -c SizeConstraintsType Model.DesignedDiffs.xafml; grep -c CaptionHorizontalAlignment Model.DesignedDiffs.xafml
The counts were 416 and 132! I can guarantee that I did not set all of those. Heck, I don't even know what SizeConstraintsType means!
I think the reason this issue has gone unnoticed is because the LayoutManagerOptions must be set to non-default values to make it happen.
Please try the scenario above and let me know what happens. Meanwhile, I'll continue to try to create a reproducible case for a non-empty LayoutViewItem.
Thank you,
Mark
Thank you for the additonal information. I have replicated the serialization issue and created a separate ticket about this unusual behavior: T286097. We will research why this happens and whether this behavior is correct or not.
As for the original issue discussed in this thread, please let me know whether you have found where the model was customized or you need further assistance. In the latter case, provide us with a sample project for review.
Michael,
Since you created a separate ticket we can close this one.
Mark