Is possible to have a different tag name in winui 3 user control? - user-controls

Is it possible to have a different tag name fo my user control?
My class looks like:
public sealed partial class ValidationControl : UserControl { ... }
and used like this:
<controls:ValidationControl Model="{x:Bind ViewModel, Mode=OneWay}" PropertyName="Name"/>
Is there some property in my user control that could change the tag name but that my class' name will continue naming ValidationControl?:
<controls:Validation Model="{x:Bind ViewModel, Mode=OneWay}" PropertyName="Name"/>
I have another class named Validation, that's why I cannot name only Validation to my control.

You could create a one-liner marker type:
public class AlternativeName : ValidationControl { }
...and instantiate this one instead of the base class:
<controls:lternativeName ...
Don't forget to also remove the sealed keyword from the definition of the existing ValidationControl class:
public partial class ValidationControl : UserControl { ... }

Related

Can I replace an attribute of a class?

In the Sales Order screen, there is this view :
public PXSelect<SiteStatus> sitestatusview;
And SiteStatus table is declared as this :
[SiteStatusAccumulator]
[PXDisableCloneAttributes()]
[Serializable]
public partial class SiteStatus : INSiteStatus, IQtyAllocated
{...
...}
SiteStatusAccumulator among its usage is to check available quantities. And I want to override this validation. Particularly the SiteStatusAccumulator.PersistInserted method. With fields, I can cache_attached and override the attributes. But with tables, how can you achieve something similar ?

Override BQL used for PXProjection on SOShipmentPlan

I have a need to override the Select statement being used for the SOShipmentPlan PXProjection/DAC, namely, removing the
And <INPlanType.isFixed, Equal<boolFalse>
condition.
I can override all of the CreateShipment() logic and bring in any other necessary routines into an SOShipmentEntry_Extension class, to the point where I finally can use my own version of a SOShipmentPlan class, but that all seems needlessly complex when all I want to do is override the select for the PXProjection attribute. Overriding CreateShipment() and supporting routines also seems like a quick way to get in trouble come time for upgrades.
So, is there an easy way to override the PXProjection's BQL, or am I stuck overriding all kinds of code?
UPDATE 1
Based on a link provided below (stackoverflow.com/a/41540659/7376238), I feel like I'm close. Here's the block of code I end up with:
namespace PX.Objects.SO
{
public class SOShipmentEntry_Extension : PXGraphExtension<SOShipmentEntry>
{
#region Event Handlers
#endregion
[Serializable]
[PXProjection(typeof(Select2<SOOrder,
InnerJoin<SOOrderType, On<SOOrder.FK.OrderType>,
InnerJoin<INItemPlan, On<INItemPlan.refNoteID, Equal<SOOrder.noteID>>,
InnerJoin<INPlanType, On<INItemPlan.FK.PlanType>>>>,
Where<INItemPlan.hold, Equal<boolFalse>,
And<INItemPlan.planQty, Greater<decimal0>,
And<INPlanType.isDemand, Equal<boolTrue>,
And<INPlanType.isForDate, Equal<boolTrue>,
And<Where<INItemPlan.fixedSource, IsNull,
Or<INItemPlan.fixedSource, NotEqual<INReplenishmentSource.transfer>>>>>>>>>))]
[PXSubstitute()]
public partial class SOShipmentPlanCst : SOShipmentPlan
{
int x = 0;
}
}
But it doesn't seem to work. Not sure of where I'm supposed to put the code. I've tried putting the class definition inside and outside of public class SOShipmentEntry_Extension : PXGraphExtension<SOShipmentEntry> class (currently inside the extension class as shown). No luck either way.
THIS ANSWER DIDN'T WORK
Fair warning... I have not done this to a PXProjection before, so you'll have to see if this works. The nature of extensions tends to allow overriding views by simply redefining them. I have not done this myself with a projection, but I suspect it will be similar. Give it a try and see if you get the desired results. All I can say about testing it is that "it compiled" when I added to my project and removed the INItemPLanType.isFixed condition.
public class SOShipmentEntry_Extension : PXGraphExtension<SOShipmentEntry>
{
[PXProjection(typeof(Select2<SOOrder,
InnerJoin<SOOrderType, On<SOOrder.FK.OrderType>,
InnerJoin<INItemPlan, On<INItemPlan.refNoteID, Equal<SOOrder.noteID>>,
InnerJoin<INPlanType, On<INItemPlan.FK.PlanType>>>>,
Where<INItemPlan.hold, Equal<boolFalse>,
And<INItemPlan.planQty, Greater<decimal0>,
And<INPlanType.isDemand, Equal<boolTrue>,
And<INPlanType.isForDate, Equal<boolTrue>,
And<Where<INItemPlan.fixedSource, IsNull, Or<INItemPlan.fixedSource, NotEqual<INReplenishmentSource.transfer>>>>>>>>>))]
public partial class SOShipmentPlan : IBqlTable { }
}

Inherited interface hides parent in Orchard framework

I created an interface ISecureStorageProvider like below.
public interface ISecureStorageProvider : IStorageProvider
{
}
Concrete implementation for ISecureStorageProvider looks like below.
public class SecureAzureBlobStorageProvider : AzureFileSystem, ISecureStorageProvider
{
}
What I found was, the class SecureAzureBlobStorageProvider gets injected for both the interfaces ISecureStorageProvider , IStorageProvider. But, I want both of them to be available, not one suppressing another.

Get the name of child class inside of super class

is there a way to get the name of a child class inside of a super class?
class ChildClass inherits SuperClass { }
class SuperClass {
notify { "$NAME_OF_CHILD_CLASS is inheriting me": }
}
The expected output would be ChildClass is inheriting me. I'd need something similar to $module_name which contains the name of the class that contains the current resource's definition.
Is there a way to achieve this? I don't mind if I need a custom function for that...

Passing parameters to UserControl constructor in c# 2.0

Is there a way to pass the parameters to the LoadControl function when loading the user control dynamically?
I found a solution that uses reflection here
All you need to do is create a descendant of the UserControl class, add a default constructor and another constructor that takes your parameters. The parameterless constructor is necessary for designer support.
public class MyControl : UserControl
{
public MyControl() : base()
{
// do initialization stuff...
}
public MyControl(int parameter) : this()
{
// do additional stuff with parameter
}
}

Resources