Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ BenchmarkDotNet.Artifacts/
project.lock.json
project.fragment.lock.json
artifacts/
**/Properties/launchSettings.json

*_i.c
*_p.c
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@namespace CustomViewItem.Blazor.Server.Editors.ButtonViewItem

<DxButton Text=@Text Click=@Click />

@code {
[Parameter]
public string Text { get; set; }
[Parameter]
public EventCallback<MouseEventArgs> Click { get; set; }
}
Original file line number Diff line number Diff line change
@@ -1,45 +1,42 @@
using System;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Blazor;
using DevExpress.ExpressApp.Blazor.Components;
using DevExpress.ExpressApp.Blazor.Components.Models;
using DevExpress.ExpressApp.Editors;
using DevExpress.ExpressApp.Model;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;

using DevExpress.ExpressApp.Blazor.Components;
namespace CustomViewItem.Blazor.Server.Editors.ButtonViewItem;

public interface IModelButtonDetailViewItemBlazor : IModelViewItem;

namespace MySolution.Module.Blazor {
public interface IModelButtonDetailViewItemBlazor : IModelViewItem { }
[ViewItem(typeof(IModelButtonDetailViewItemBlazor))]
public class ButtonDetailViewItemBlazor(IModelViewItem model, Type objectType) :
ViewItem(objectType, model.Id),
IComponentContentHolder,
IComplexViewItem
{
public ButtonModel ComponentModel => componentModel;

private ButtonModel componentModel;
private XafApplication application;

[ViewItem(typeof(IModelButtonDetailViewItemBlazor))]
public class ButtonDetailViewItemBlazor : ViewItem, IComplexViewItem {
public class ButtonHolder : IComponentContentHolder {
public ButtonHolder(ButtonModel componentModel) {
ComponentModel = componentModel;
}
public ButtonModel ComponentModel { get; }
RenderFragment IComponentContentHolder.ComponentContent => ComponentModelObserver.Create(ComponentModel, ButtonRenderer.Create(ComponentModel));
}
private XafApplication application;
public ButtonDetailViewItemBlazor(IModelViewItem model, Type objectType) : base(objectType, model.Id) { }
void IComplexViewItem.Setup(IObjectSpace objectSpace, XafApplication application) {
this.application = application;
}
protected override object CreateControlCore() => new ButtonHolder(new ButtonModel());
protected override void OnControlCreated() {
if (Control is ButtonHolder holder) {
holder.ComponentModel.Text = "Click me!";
holder.ComponentModel.Click += ComponentModel_Click;
}
base.OnControlCreated();
}
public override void BreakLinksToControl(bool unwireEventsOnly) {
if (Control is ButtonHolder holder) {
holder.ComponentModel.Click -= ComponentModel_Click;
}
base.BreakLinksToControl(unwireEventsOnly);
}
private void ComponentModel_Click(object sender, EventArgs e) {
application.ShowViewStrategy.ShowMessage("Action is executed!");
}
RenderFragment IComponentContentHolder.ComponentContent =>
ComponentModelObserver.Create(componentModel, componentModel.GetComponentContent());
void IComplexViewItem.Setup(IObjectSpace objectSpace, XafApplication application) {
this.application = application;
}

protected override object CreateControlCore() {
componentModel = new ButtonModel
{
Text = "Click me!",
Click = EventCallback.Factory.Create<MouseEventArgs>(this, ComponentModel_Click),
};
return componentModel;
}
private void ComponentModel_Click() {
application.ShowViewStrategy.ShowMessage("Action is executed!");
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
using System;
using DevExpress.ExpressApp.Blazor.Components.Models;
using DevExpress.ExpressApp.Blazor.Components.Models;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;

namespace MySolution.Module.Blazor {
public class ButtonModel : ComponentModelBase {
public string Text {
get => GetPropertyValue<string>();
set => SetPropertyValue(value);
}
public void ClickFromUI() {
Click?.Invoke(this, EventArgs.Empty);
}
public event EventHandler Click;
namespace CustomViewItem.Blazor.Server.Editors.ButtonViewItem;

public class ButtonModel : ComponentModelBase {
public string Text {
get => GetPropertyValue<string>();
set => SetPropertyValue(value);
}
public EventCallback<MouseEventArgs> Click {
get => GetPropertyValue<EventCallback<MouseEventArgs>>();
set => SetPropertyValue(value);
}

public override Type ComponentType => typeof(Button);
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"profiles": {
"CustomViewItem.Blazor.Server": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<None Include="Editors\ButtonViewItem\ButtonRenderer.razor" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="DevExpress.ExpressApp.Blazor" Version="25.2.1-alpha-25302" />
<PackageReference Include="DevExpress.ExpressApp.CodeAnalysis" Version="25.2.1-alpha-25302" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@namespace CustomViewItemXPO.Blazor.Server.Editors.ButtonViewItem

<DxButton Text=@Text Click=@Click />

@code {
[Parameter]
public string Text { get; set; }
[Parameter]
public EventCallback<MouseEventArgs> Click { get; set; }
}
Original file line number Diff line number Diff line change
@@ -1,45 +1,42 @@
using System;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Blazor;
using DevExpress.ExpressApp.Blazor.Components;
using DevExpress.ExpressApp.Blazor.Components.Models;
using DevExpress.ExpressApp.Editors;
using DevExpress.ExpressApp.Model;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;

using DevExpress.ExpressApp.Blazor.Components;
namespace CustomViewItemXPO.Blazor.Server.Editors.ButtonViewItem;

public interface IModelButtonDetailViewItemBlazor : IModelViewItem;

namespace MySolution.Module.Blazor {
public interface IModelButtonDetailViewItemBlazor : IModelViewItem { }
[ViewItem(typeof(IModelButtonDetailViewItemBlazor))]
public class ButtonDetailViewItemBlazor(IModelViewItem model, Type objectType) :
ViewItem(objectType, model.Id),
IComponentContentHolder,
IComplexViewItem
{
public ButtonModel ComponentModel => componentModel;

private ButtonModel componentModel;
private XafApplication application;

[ViewItem(typeof(IModelButtonDetailViewItemBlazor))]
public class ButtonDetailViewItemBlazor : ViewItem, IComplexViewItem {
public class ButtonHolder : IComponentContentHolder {
public ButtonHolder(ButtonModel componentModel) {
ComponentModel = componentModel;
}
public ButtonModel ComponentModel { get; }
RenderFragment IComponentContentHolder.ComponentContent => ComponentModelObserver.Create(ComponentModel, ButtonRenderer.Create(ComponentModel));
}
private XafApplication application;
public ButtonDetailViewItemBlazor(IModelViewItem model, Type objectType) : base(objectType, model.Id) { }
void IComplexViewItem.Setup(IObjectSpace objectSpace, XafApplication application) {
this.application = application;
}
protected override object CreateControlCore() => new ButtonHolder(new ButtonModel());
protected override void OnControlCreated() {
if (Control is ButtonHolder holder) {
holder.ComponentModel.Text = "Click me!";
holder.ComponentModel.Click += ComponentModel_Click;
}
base.OnControlCreated();
}
public override void BreakLinksToControl(bool unwireEventsOnly) {
if (Control is ButtonHolder holder) {
holder.ComponentModel.Click -= ComponentModel_Click;
}
base.BreakLinksToControl(unwireEventsOnly);
}
private void ComponentModel_Click(object sender, EventArgs e) {
application.ShowViewStrategy.ShowMessage("Action is executed!");
}
RenderFragment IComponentContentHolder.ComponentContent =>
ComponentModelObserver.Create(componentModel, componentModel.GetComponentContent());
void IComplexViewItem.Setup(IObjectSpace objectSpace, XafApplication application) {
this.application = application;
}

protected override object CreateControlCore() {
componentModel = new ButtonModel
{
Text = "Click me!",
Click = EventCallback.Factory.Create<MouseEventArgs>(this, ComponentModel_Click),
};
return componentModel;
}
private void ComponentModel_Click() {
application.ShowViewStrategy.ShowMessage("Action is executed!");
}
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
using System;
using DevExpress.ExpressApp.Blazor.Components.Models;
using DevExpress.ExpressApp.Blazor.Components.Models;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;

namespace MySolution.Module.Blazor {
public class ButtonModel : ComponentModelBase {
public string Text {
get => GetPropertyValue<string>();
set => SetPropertyValue(value);
}
public void ClickFromUI() {
Click?.Invoke(this, EventArgs.Empty);
}
public event EventHandler Click;
namespace CustomViewItemXPO.Blazor.Server.Editors.ButtonViewItem;

public class ButtonModel : ComponentModelBase {
public string Text {
get => GetPropertyValue<string>();
set => SetPropertyValue(value);
}
public EventCallback<MouseEventArgs> Click {
get => GetPropertyValue<EventCallback<MouseEventArgs>>();
set => SetPropertyValue(value);
}
}

public override Type ComponentType => typeof(Button);
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"profiles": {
"CustomViewItemXPO.Blazor.Server": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}