BcdLib has been renamed BcdLib.BcdForm
. Please to https://github.com/BcdLib/BcdForm learn the latest content of this component.
Use Blazor like WinForm. Just new a component and show it like here:
var form = new Component();
await form.ShowAsync();
+ <link href="_content/BcdLib/index.css" rel="stylesheet">
+ <script src="_content/BcdLib/index.js"></script>
<Router ...>
...
</Router>
+ <BcdFormContainer />
For server side:
public static void Main(string[] args)
{
var host = CreateHostBuilder(args).Build();
+ host.Services.UseBcdForm();
host.Run();
}
For WASM:
public static async Task Main(string[] args)
{
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
...
var host = builder.Build();
+ host.Services.UseBcdForm();
await host.RunAsync();
}
You must override InitComponent method. To remind developers to set some properties of the component, such as Title, it is defined as an abstract method.
Sample:
@inherits BcdForm
...
@code {
protected override void InitComponent()
{
...
}
}
Jsut like using winform:
var form = new BcdFormChild();
await form.ShowAsync();
See BcdSample.Common/BcdForms for examples.
You cannot interact with child components in the root component that inherits BcdForm (only limit to the root component), such as EventCallback or @bind.
But you can using Action or Func instead of EventCallback, because Action or Func do not need a RenderHandler.
Demo see BcdLib/BcdSample.Common/BcdForms/Nesting.razor
.
Property | Type | Summary | Default |
---|---|---|---|
Title | string | the title of form. Default value is BcdForm | "BcdForm" |
Name | string | Unique identification, it will be used as the Id attribute of the form root DOM. If it is not defined, it will be generated by default | Bcd-[Guid] |
Width | int | The width of the form, in pixels | 520 |
MinPosition | MinPosition | Where the form is minimized | MinPosition.RightBottom |
BodyStyle | string | form body's style | null |
DestroyOnClose | bool | Remove from DOM when closing. If DestroyOnClose is false, be sure to use a global variable to accept the instance of BcdForm |
true |
EnableHeader | bool | Allow header to be displayed | true |
ShowMask | bool | Allow Mask to be displayed. Default is false | false |
MaskClosable | bool | Whether to close the form when the mask is clicked, if ShowMask is true. | true |
MaskStyle | string | the style of Mask, if ShowMask is true. | null |
MinimizeBox | bool | Allow minimization | true |
MinimizeBox | bool | Allow maximum | true |
Draggable | bool | Allow drag | false |
DragInViewport | bool | Drag is only allowed in the viewport, if Draggable is true. | true |
Visible | bool | Only can get. Whether the form is visible or not | -- |
HasDestroyed | bool | Only can get. Whether the form has been removed from DOM | true |
FormState | FormState | Only can get. The form's state: maximize, minimize or normalize | FormState.Normal |
Property | Type | Summary | Default |
---|---|---|---|
ServiceScope | IServiceScope | readonly. IServiceScope for accept dependent injection services. If you use ServiceScope in the subclass, note that it will be released at Dispose; If you don't use ServiceScope in the subclass, you can still use ShowAsync after Disposed. |
-- |
ServiceProvider | IServiceProvider | readonly. IServiceProvider for accept dependent injection services. | -- |
IsDisposed | bool | readonly. Has the object been released | false |
Name | Type | Summary | parameters | return |
---|---|---|---|---|
InitComponent() | protected abstract | InitComponent will be triggered in constructors, and it's before OnShowingAsync when the form is not in the DOM. |
-- | void |
OnShowingAsync(CancelEventArgs e) | protected virtual | Trigger before displaying form. The display can be cancelled by CancelEventArgs. | -- | Task |
OnClosingAsync(CancelEventArgs e) | protected virtual | Trigger before closing form. The close can be cancelled by CancelEventArgs | -- | Task |
OnDestroyingAsync(CancelEventArgs e) | protected virtual | Trigger before the form destroying (removing) from DOM. The destroy Can be cancelled by CancelEventArgs | -- | Task |
JsInvokeVoidAsync(string func, params object[] args) | protected | the proxy of IJsRuntime.InvokeVoidAsync | see IJsRuntime.InvokeVoidAsync | Task |
JsInvokeAsync(string func, params object[] args) | protected | the proxy of IJsRuntime.InvokeAsync | see IJsRuntime.InvokeVoidAsync | ValueTask |
InvokeStateHasChanged() | protected | StateHasChanged adapter | -- | void |
InvokeStateHasChangedAsync() | protected | InvokeAsync(StateHasChanged) adapter | -- | Task |
AfterBcdRender(bool firstRender) | protected virtual | it will trigger in OnAfterRenderAsync, and It will be called before AfterBcdRenderAsync | firstRender: Is the form rendered for the first time | void |
AfterBcdRenderAsync(bool firstRender) | protected virtual | it will trigger in OnAfterRenderAsync | firstRender: Is the form rendered for the first time | Task |
Dispose(bool disposing) | protected virtual | dispose resources | disposing: true to dispose the form's resources | void |
- AntDesign: form's style