diff --git a/blazor-toc.html b/blazor-toc.html index 42b9e500c0..d2ce64fbf2 100644 --- a/blazor-toc.html +++ b/blazor-toc.html @@ -243,6 +243,8 @@
  • Release Notes
  • +
  • Skills
  • +
  • Agentic UI Builder
  • Smart Components
  • -
  • Skills - -
  • Integration diff --git a/blazor/Release-Notes/34.1.29.md b/blazor/Release-Notes/34.1.29.md new file mode 100644 index 0000000000..3e3f5e9029 --- /dev/null +++ b/blazor/Release-Notes/34.1.29.md @@ -0,0 +1,96 @@ +--- +title: Essential Studio for Blazor Release Notes +description: Learn here about the controls in the Essential Studio for Blazor 2026 Volume 2 Main Release - Release Notes +platform: blazor +documentation: ug +--- + +# Essential Studio for Blazor - v34.1.29 Release Notes + +{% include release-info.html date="July 06, 2026" version="v34.1.29" passed="97643" failed="0" %} + +{% directory path: _includes/release-notes/v34.1.29 %} + +{% include {{file.url}} %} + +{% enddirectory %} + +## Test Results + +| Component Name | Test Cases | Passed | Failed | Remarks | +|---------------|------------|--------|--------|---------| +| 3DChart | 376 | 376 | 0 | All Passed | +| Accordion | 232 | 232 | 0 | All Passed | +| AiAssistView | 463 | 463 | 0 | All Passed | +| Appbar | 103 | 103 | 0 | All Passed | +| Autocomplete | 484 | 484 | 0 | All Passed | +| BarcodeGenerator | 440 | 440 | 0 | All Passed | +| Breadcrumb | 137 | 137 | 0 | All Passed | +| Bulletchart | 241 | 241 | 0 | All Passed | +| Button | 255 | 255 | 0 | All Passed | +| Calendar | 146 | 146 | 0 | All Passed | +| Carousel | 177 | 177 | 0 | All Passed | +| Charts | 6709 | 6709 | 0 | All Passed | +| ChartWizard | 317 | 317 | 0 | All Passed | +| ChatUI | 243 | 243 | 0 | All Passed | +| Chips | 214 | 214 | 0 | All Passed | +| CircularGauge | 1015 | 1015 | 0 | All Passed | +| ColorPicker | 115 | 115 | 0 | All Passed | +| ComboBox | 620 | 620 | 0 | All Passed | +| DashboardLayout | 262 | 262 | 0 | All Passed | +| DataForm | 548 | 548 | 0 | All Passed | +| DataGrid | 10702 | 10702 | 0 | All Passed | +| DatePicker | 580 | 580 | 0 | All Passed | +| DateRangePicker | 368 | 368 | 0 | All Passed | +| DateTimePicker | 475 | 475 | 0 | All Passed | +| Diagram | 17089 | 17089 | 0 | All Passed | +| Dialog | 488 | 488 | 0 | All Passed | +| DropdownList | 920 | 920 | 0 | All Passed | +| Dropdowntree | 214 | 214 | 0 | All Passed | +| FileManager | 3460 | 3460 | 0 | All Passed | +| FileUpload | 725 | 725 | 0 | All Passed | +| FloatingActionButton | 128 | 128 | 0 | All Passed | +| Gantt | 9368 | 9368 | 0 | All Passed | +| HeatMap | 419 | 419 | 0 | All Passed | +| ImageEditor | 3745 | 3745 | 0 | All Passed | +| InPlaceEditor | 768 | 768 | 0 | All Passed | +| InputMask | 172 | 172 | 0 | All Passed | +| Kanban | 543 | 543 | 0 | All Passed | +| LinearGauge | 801 | 801 | 0 | All Passed | +| ListBox | 139 | 139 | 0 | All Passed | +| ListView | 442 | 442 | 0 | All Passed | +| Maps | 1756 | 1756 | 0 | All Passed | +| Mention | 154 | 154 | 0 | All Passed | +| Menu | 398 | 398 | 0 | All Passed | +| Message | 211 | 211 | 0 | All Passed | +| MultiselectDropdown | 907 | 907 | 0 | All Passed | +| NumericTextbox | 467 | 467 | 0 | All Passed | +| OtpInput | 123 | 123 | 0 | All Passed | +| PivotTable | 1846 | 1846 | 0 | All Passed | +| ProgressBar | 199 | 199 | 0 | All Passed | +| progressbutton | 101 | 101 | 0 | All Passed | +| QueryBuilder | 585 | 585 | 0 | All Passed | +| RangeNavigator | 220 | 220 | 0 | All Passed | +| Rating | 106 | 106 | 0 | All Passed | +| Ribbon | 548 | 548 | 0 | All Passed | +| RichTextEditor | 3218 | 3218 | 0 | All Passed | +| Scheduler | 6768 | 6768 | 0 | All Passed | +| Sidebar | 150 | 150 | 0 | All Passed | +| Slider | 273 | 273 | 0 | All Passed | +| SmithChart | 260 | 260 | 0 | All Passed | +| Sparkline | 229 | 229 | 0 | All Passed | +| SpeedDial | 353 | 353 | 0 | All Passed | +| Splitter | 193 | 193 | 0 | All Passed | +| Stepper | 218 | 218 | 0 | All Passed | +| StockChart | 359 | 359 | 0 | All Passed | +| Tabs | 1085 | 1085 | 0 | All Passed | +| TextArea | 126 | 126 | 0 | All Passed | +| Textbox | 685 | 685 | 0 | All Passed | +| Timeline | 182 | 182 | 0 | All Passed | +| TimePicker | 421 | 421 | 0 | All Passed | +| Toast | 234 | 234 | 0 | All Passed | +| Toolbar | 236 | 236 | 0 | All Passed | +| Tooltip | 135 | 135 | 0 | All Passed | +| TreeGrid | 8113 | 8113 | 0 | All Passed | +| TreeMap | 775 | 775 | 0 | All Passed | +| TreeView | 1366 | 1366 | 0 | All Passed | \ No newline at end of file diff --git a/blazor/skills/agentic-ui-builder.md b/blazor/agentic-ui-builder.md similarity index 100% rename from blazor/skills/agentic-ui-builder.md rename to blazor/agentic-ui-builder.md diff --git a/blazor/appbar/getting-started-with-server-app.md b/blazor/appbar/getting-started-with-server-app.md index 97ff833ded..7c0cc47d3d 100644 --- a/blazor/appbar/getting-started-with-server-app.md +++ b/blazor/appbar/getting-started-with-server-app.md @@ -1,6 +1,6 @@ --- layout: post -title: Getting Started with AppBar in Blazor Server App | Syncfusion® +title: Getting Started with Blazor AppBar in Blazor Server App | Syncfusion description: Checkout and learn about the documentation for getting started with Blazor AppBar Component in Blazor Server App. platform: Blazor component: AppBar diff --git a/blazor/appbar/getting-started-with-web-app.md b/blazor/appbar/getting-started-with-web-app.md index b4202b8674..5ef9465804 100644 --- a/blazor/appbar/getting-started-with-web-app.md +++ b/blazor/appbar/getting-started-with-web-app.md @@ -1,6 +1,6 @@ --- layout: post -title: Getting Started with AppBar Component in Blazor Web App | Syncfusion® +title: Getting Started with Blazor AppBar in Blazor Web App | Syncfusion description: Checkout and learn about the documentation for getting started with Blazor AppBar Component in Blazor Web App. platform: Blazor component: AppBar @@ -243,3 +243,4 @@ N> [View Sample in GitHub](https://github.com/SyncfusionExamples/Blazor-Getting- 1. [Getting Started with Blazor for client-side in .NET Core CLI](https://blazor.syncfusion.com/documentation/getting-started/blazor-webassembly-dotnet-cli) 2. [Getting Started with Blazor for client-side in Visual Studio](https://blazor.syncfusion.com/documentation/getting-started/blazor-webassembly-visual-studio) 3. [Getting Started with Blazor for server-side in .NET Core CLI](https://blazor.syncfusion.com/documentation/getting-started/blazor-server-side-dotnet-cli) + diff --git a/blazor/chart/series-label.md b/blazor/chart/series-label.md new file mode 100644 index 0000000000..4642189dcf --- /dev/null +++ b/blazor/chart/series-label.md @@ -0,0 +1,194 @@ +--- +layout: post +title: Series Label in Blazor Charts Component | Syncfusion +description: Check out and learn here all about the Series label in the Syncfusion Blazor Charts component and much more. +platform: Blazor +control: Chart +documentation: ug +keywords: Blazor Chart series label, series label, chart labels, inline series labels, chart series customization, SeriesLabelSettings +--- + +# Series Label in Blazor Charts Component + +The series label feature displays the name of each series directly within the chart area. This improves readability by helping users identify series inline and reduces reliance on the legend. + +This feature is especially useful in multi-series visualizations and exported charts, where quick in-chart identification is important.Series labels can be enabled and customized using the `SeriesLabelSettings` property. + +N> **Supported Series Types:** Series labels are available for Line, Area, Scatter, Column, Bar, Polar Line, and Radar Line chart types. + +## Enable series labels + +To display series labels, set the `Visible` property of `SeriesLabelSettings` to `true` for the required series. + +```cshtml + +@using Syncfusion.Blazor.Charts + + + + + + + + + + + + + + + + + + + + + + + +@code { + public class MetricData + { + public string Month { get; set; } + public double Value { get; set; } + } + + public List ActiveUsersData = new() + { + new MetricData { Month = "Feb", Value = 420 }, + new MetricData { Month = "Mar", Value = 460 }, + new MetricData { Month = "Apr", Value = 445 }, + new MetricData { Month = "May", Value = 495 }, + new MetricData { Month = "Jun", Value = 535 } + }; + + public List SupportTicketsData = new() + { + new MetricData { Month = "Feb", Value = 210 }, + new MetricData { Month = "Mar", Value = 240 }, + new MetricData { Month = "Apr", Value = 225 }, + new MetricData { Month = "May", Value = 260 }, + new MetricData { Month = "Jun", Value = 275 } + }; + + public List FeatureRequestsData = new() + { + new MetricData { Month = "Feb", Value = 65 }, + new MetricData { Month = "Mar", Value = 78 }, + new MetricData { Month = "Apr", Value = 72 }, + new MetricData { Month = "May", Value = 95 }, + new MetricData { Month = "Jun", Value = 108 } + }; +} + +``` + + +![Blazor line chart displaying inline series labels](images/series-label/blazor-line-chart-series-label.webp) + +## Customization + +You can customize the appearance of the series label using the following properties. + +### SeriesLabelSettings Properties + +Configure the main series label appearance: + +In the `SeriesLabelSettings`: +* `Visible`: Enables or disables the display of series labels. Set to `true` to display the label for the corresponding series. +* `Text`: Specifies the custom text to be displayed in the series label. If this property is not set, the label displays the corresponding series name by default. +* `Background`: Specifies the background color of the series label. This helps the label stand out clearly within the chart area. +* `Opacity`: Specifies the transparency level of the series label. The accepted range is from 0 to 1, where 0 represents full transparency and 1 represents full opacity. For example, set `Opacity="0.5"` for 50% transparency. +* `ShowOverlapText`: Determines whether overlapping series labels should be displayed. This is useful when labels overlap because the corresponding series are positioned close to one another. + +In the `SeriesLabelBorder`: +* `Color`: Specifies the border color of the series label. This can be used to visually separate the label from the chart background. +* `Width`: Specifies the width of the border around the series label. A higher value makes the border more visible. + +In the `SeriesLabelFont`: +* `Size`: Specifies the font size of the label text. +* `Color`: Specifies the font color of the label text. +* `FontFamily`: Specifies the font family of the label text. +* `FontWeight`: Specifies the font weight of the label text. Valid values include `normal`, `bold`, `600`, `700`, etc. (CSS font-weight format). + +```cshtml + +@using Syncfusion.Blazor.Charts + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +@code { + public class MetricData + { + public string Month { get; set; } + public double Value { get; set; } + } + + public List ActiveUsersData = new() + { + new MetricData { Month = "Feb", Value = 420 }, + new MetricData { Month = "Mar", Value = 460 }, + new MetricData { Month = "Apr", Value = 445 }, + new MetricData { Month = "May", Value = 495 }, + new MetricData { Month = "Jun", Value = 535 } + }; + + public List SupportTicketsData = new() + { + new MetricData { Month = "Feb", Value = 210 }, + new MetricData { Month = "Mar", Value = 240 }, + new MetricData { Month = "Apr", Value = 225 }, + new MetricData { Month = "May", Value = 260 }, + new MetricData { Month = "Jun", Value = 275 } + }; + + public List FeatureRequestsData = new() + { + new MetricData { Month = "Feb", Value = 65 }, + new MetricData { Month = "Mar", Value = 78 }, + new MetricData { Month = "Apr", Value = 72 }, + new MetricData { Month = "May", Value = 95 }, + new MetricData { Month = "Jun", Value = 108 } + }; +} + +``` + + +![Blazor line chart with customized series label background, font, and border](images/series-label/blazor-line-chart-series-label-customization.webp) + +## See also + +* [Data Label](./data-labels) +* [Legend](./legend) + +N> Refer to the [Blazor Charts](https://www.syncfusion.com/blazor-components/blazor-charts) feature tour page to explore the available chart features. You can also check the [Blazor Chart Example](https://blazor.syncfusion.com/demos/chart/line?theme=bootstrap5) to learn how chart types are used to visualize data trends over equal intervals. diff --git a/blazor/chat-ui/content-security-policy.md b/blazor/chat-ui/content-security-policy.md new file mode 100644 index 0000000000..7f80bab7be --- /dev/null +++ b/blazor/chat-ui/content-security-policy.md @@ -0,0 +1,75 @@ +--- +layout: post +title: Chat UI - Strict CSP Feature Limitations | Syncfusion® +description: Details on features in Blazor Chat UI Component that require Content Security Policy (CSP) relaxation and much more details. +platform: Blazor +control: Chat UI +documentation: ug +--- + +# Chat UI - Content Security Policy Limitations + +## What's supported under strict CSP ? + +The Syncfusion® Blazor **Chat UI** component supports most features under strict Content Security Policy without needing `'unsafe-inline'`. You can safely use: + +- Sending and receiving messages +- Rendering text, rich text, and custom message templates +- User and author details (avatar, name, timestamp) +- Typing indicator +- Suggested/quick reply actions +- Theming and static customizations + +## What requires *'unsafe-inline'* ? + +The following feature requires the `style-src 'unsafe-inline'` directive: + +### 1. Load on demand + +The **Load on demand** feature internally uses the `Virtualize` component to render chat messages efficiently for large conversation lists. The `Virtualize` component dynamically applies inline styles to manage item placeholders, spacing, and scroll positioning while loading data on demand, which requires `'unsafe-inline'` to function correctly. + +> **Note:** Core features including message rendering, templates, typing indicator, suggestions, and theming operate fully under strict CSP without requiring `'unsafe-inline'`. Only the **Load on demand** feature is impacted under strict CSP. + +## Recommended CSP configurations + +### Strict CSP (without Load on demand) + +Use this configuration if you don't need the **Load on demand** feature: + +```html + +``` + +This configuration maintains full security for the Chat UI component's messaging experience. + +### Relaxed CSP (with Load on demand) + +Include `'unsafe-inline'` if you need the **Load on demand** feature: + +```html + +``` + +> Use this only when **Load on demand** (virtualized message loading) is essential to your application. + +## See also + +* [Content security policy in Blazor components](https://blazor.syncfusion.com/documentation/common/content-security-policy) \ No newline at end of file diff --git a/blazor/check-box/customization.md b/blazor/check-box/customization.md new file mode 100644 index 0000000000..910942b8e8 --- /dev/null +++ b/blazor/check-box/customization.md @@ -0,0 +1,297 @@ +--- +layout: post +title: CheckBox customization in Blazor CheckBox Component | Syncfusion® +description: Checkout and learn here all the features about Customized Checkbox in Blazor CheckBox component and more details. +platform: Blazor +control: Checkbox +documentation: ug +--- + +# CheckBox customization in Blazor CheckBox Component + +## Customize Styles and Appearances + +To modify the [Blazor CheckBox](https://www.syncfusion.com/blazor-components/blazor-checkbox) appearance, you need to override the default CSS of CheckBox component. Find the list of CSS classes and their corresponding section in CheckBox. Also, you have an option to create your own custom theme for the controls using our [Theme Studio](https://blazor.syncfusion.com/themestudio/?theme=material). + +|CSS Class | Purpose of Class| +|-----|-----| +|.e-checkbox-wrapper .e-frame|To customize the checkbox frame. | +|.e-checkbox-wrapper:hover .e-frame|To customize the checkbox frame on hover. | +|.e-checkbox-wrapper .e-label|To customize the checkbox label. | +|.e-checkbox-wrapper:hover .e-label|To customize the checkbox label on hover. | +|.e-checkbox-wrapper .e-frame.e-check|To customize the checked checkbox. | +|.e-checkbox-wrapper:hover .e-frame.e-check|To customize the checked checkbox when hover. | + +## Customize Checkbox appearance + +You can customize the appearance of the Checkbox component using the CSS rules. Define own CSS rules according to your requirement and assign the class name to the +[CssClass](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Buttons.SfCheckBox-1.html) property. + +The background and border color of the Checkbox is customized through the custom classes to create primary, success, warning, and danger info type of checkbox. + +```cshtml +@using Syncfusion.Blazor.Buttons + +
    +
    +
    +
    + + +@code { + private bool isPrimaryChecked = true; + private bool isSuccessChecked = true; + private bool isInfoChecked = true; + private bool isWarningChecked = true; + private bool isDangerChecked = true; +} + + + +``` +{% previewsample "https://blazorplayground.syncfusion.com/embed/BZVKshBQrJbnEQzO?appbar=false&editor=false&result=true&errorlist=false&theme=bootstrap5" backgroundimage "[Customizing Appearance of Blazor CheckBox](./images/blazor-checkbox-appearance-customization.webp)" %} + +## Customize width and height + +The height and width of the Checkbox component can be customized by setting `height` and `width` properties in `styles` + +The following section explains about how to customize the height and width of the Checkbox component. + +```cshtml +@using Syncfusion.Blazor.Buttons + + + +@code { + private bool isChecked = true; +} + + + +``` +{% previewsample "https://blazorplayground.syncfusion.com/embed/BtrUWLLGVTFECslm?appbar=false&editor=false&result=true&errorlist=false&theme=bootstrap5" backgroundimage "[Customizing Height and Width of Blazor CheckBox](./images/blazor-checkbox-height-width-customization.webp)" %} + +## Custom frame + +Checkbox frame can be customized as per the requirement by adding CSS rules. + +In the following example, to-do list is displayed with round checkbox by changing `border-radius` as `100%` by adding `e-custom` class. + +```cshtml +@using Syncfusion.Blazor.Buttons + +
    +
    +
    + + +@code { + private bool isChecked = true; + private bool isRentChecked = true; + private bool isDinnerChecked = false; + private bool isArticleChecked = false; +} + + + +``` +{% previewsample "https://blazorplayground.syncfusion.com/embed/BZrgirhGhJYCyqDJ?appbar=false&editor=false&result=true&errorlist=false&theme=bootstrap5" backgroundimage "[Customizing Blazor CheckBox Frame](./images/blazor-checkbox-frame-customization.webp)" %} + +## Custom check icon + +Checkbox check icon can be customized as per the requirement by adding CSS rules. + +In the following example, the check icon can be customized by changing check icon content, background and border color in focus and hovered states by adding `e-checkicon` class. + +```cshtml +@using Syncfusion.Blazor.Buttons + +
    +
    +
    + + +@code { + private bool isChecked = true; + private bool isRentChecked = true; + private bool isDinnerChecked = true; + private bool isArticleChecked = false; +} + + + +``` +{% previewsample "https://blazorplayground.syncfusion.com/embed/rjBgWrLGrpkSQSUL?appbar=false&editor=false&result=true&errorlist=false&theme=bootstrap5" backgroundimage "[Customizing Check Icon in Blazor CheckBox](./images/blazor-checkbox-check-icon-customization.webp)" %} + +## Right-To-Left in Blazor CheckBox Component + +Checkbox component has RTL support. This can be achieved by setting [EnableRtl](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Buttons.SfCheckBox-1.html) as `true`. + +The following example illustrates how to enable right-to-left support in Checkbox component. + +```cshtml +@using Syncfusion.Blazor.Buttons + + + +@code { + private bool isChecked = true; +} + +``` +{% previewsample "https://blazorplayground.syncfusion.com/embed/htVgiLhmVyZvKJzz?appbar=false&editor=false&result=true&errorlist=false&theme=bootstrap5" backgroundimage "[Right to Left in Blazor CheckBox](./images/blazor-checkbox-right-to-left.webp)" %} + +## Model Binding in Blazor CheckBox Component + +To get start quickly with Model Binding in Blazor CheckBox Component, you can check on this video: + +{% youtube +"youtube:https://www.youtube.com/watch?v=4vMuReo0Hz4"%} + +This section demonstrates the strongly typed extension support in Checkbox. The view that can bind with any model is called as strongly typed view. You can bind any class as model to view, access model properties on that view, and use data associated with model to render the component. + +In this sample, first check the option and click the submit button to post the selected value in the Checkbox. When the value is not checked, validation error message will be shown below the Checkbox. + +```csharp + +@using Syncfusion.Blazor.Buttons +@using System.ComponentModel.DataAnnotations + + + +
    + + +
    + +
    + +@code { + public Annotation Annotate = new Annotation(); + public class Annotation + { + [Range(typeof(bool), "true", "true", ErrorMessage = "You need to agree to the Terms and Conditions")] + public bool Check { get; set; } + } + public Dictionary Submit = new Dictionary() + { + { "type", "submit"} + }; +} + +``` +{% previewsample "https://blazorplayground.syncfusion.com/embed/LjhKMVrmrJkahhmZ?appbar=false&editor=false&result=true&errorlist=false&theme=bootstrap5" backgroundimage "[Model Binding in Blazor CheckBox](./images/blazor-checkbox-model-binding.webp)" %} \ No newline at end of file diff --git a/blazor/common/aot-compilation/reduce-size-of-blazor-wasm.md b/blazor/common/aot-compilation/reduce-size-of-blazor-wasm.md index 00031960ff..aa0fd621e2 100644 --- a/blazor/common/aot-compilation/reduce-size-of-blazor-wasm.md +++ b/blazor/common/aot-compilation/reduce-size-of-blazor-wasm.md @@ -117,7 +117,7 @@ To [enable Intermediate Language trimming](https://learn.microsoft.com/en-us/dot ### Final Evaluation -To evaluate application size, a Blazor WebAssembly test application was configured with components, specifically featuring the Blazor Grid with paging enabled. +To evaluate application size, a Blazor WebAssembly test application was configured with Blazor components, specifically featuring the Blazor Grid with paging enabled. | AOT Status | With Trim | Without Trim | |-----------------------|----------------------|----------------------| diff --git a/blazor/common/how-to/component-configuration-issues.md b/blazor/common/how-to/component-configuration-issues.md new file mode 100644 index 0000000000..4817c65475 --- /dev/null +++ b/blazor/common/how-to/component-configuration-issues.md @@ -0,0 +1,414 @@ +--- +layout: post +title: Resolving Component Configuration Issues in Blazor | Syncfusion® +description: Comprehensive guide to resolving Blazor component configuration issues including SignalR, namespaces, and data binding problems +platform: Blazor +control: Common +documentation: ug +--- + +# Resolving Component Configuration Issues in Blazor + +This guide explains how to resolve common component configuration issues when building Blazor applications with **[Blazor components](https://www.syncfusion.com/blazor-components)**. Proper component configuration ensures smooth functionality and optimal performance. + +Common configuration issues relate to: + +* SignalR configuration for large data transfers +* Namespace imports and component resolution +* Type safety and field mapping in data-bound components + +N> This guide is intended for Blazor components version 33.2.3 or later. Some details may differ in earlier versions or older .NET releases. + +## Issue 1: Incorrect SignalR configuration for large data + +**Symptom**: SignalR connection errors, timeouts, or exceptions when working with large datasets in Server render mode. Components like [Blazor DataGrid](https://www.syncfusion.com/blazor-components/blazor-datagrid), [Blazor File Manager](https://www.syncfusion.com/blazor-components/blazor-file-manager) may fail to load large amounts of data. The browser console may show errors like `Connection disconnected with error 'Error: Server returned an error on close: Connection closed with an error.'` These issues can cause data loading failures, frequent connection drops, poor user experience, and limited functionality for data-intensive components. + +**Root cause**: The default SignalR maximum incoming message size is 32 KB, which is too small for large data transfers. + +**Solution**: Configure SignalR with an appropriate message size limit in `~/Program.cs`. + +{% tabs %} +{% highlight C# tabtitle="Blazor Web App (.NET 8+) - Server" %} + +var builder = WebApplication.CreateBuilder(args); + +// Configure SignalR with increased message size +builder.Services.AddSignalR(options => +{ + // Default is 32 KB. Increase only as needed for your scenario. + options.MaximumReceiveMessageSize = 5242880; // 5 MB in bytes + + // Optional: Configure other SignalR options + options.EnableDetailedErrors = builder.Environment.IsDevelopment(); + options.HandshakeTimeout = TimeSpan.FromSeconds(30); + options.KeepAliveInterval = TimeSpan.FromSeconds(15); + options.ClientTimeoutInterval = TimeSpan.FromSeconds(30); +}); + +builder.Services.AddRazorComponents() + .AddInteractiveServerComponents(); + +builder.Services.AddSyncfusionBlazor(); + +var app = builder.Build(); + +{% endhighlight %} +{% endtabs %} + +### Component-specific recommendations + +| Component | Guidance | Reason | +|-----------|----------|--------| +| [Blazor DataGrid](https://www.syncfusion.com/blazor-components/blazor-datagrid) | Increase the limit only as required by the size of the payload being transferred | Large datasets can exceed the default 32 KB SignalR limit | +| [Blazor File Manager](https://www.syncfusion.com/blazor-components/blazor-file-manager) | Use chunked uploads and transfer only the required data | Large file operations are better handled in smaller chunks | + +### Advanced SignalR configuration + +{% tabs %} +{% highlight C# tabtitle="Program.cs" %} + +var builder = WebApplication.CreateBuilder(args); + +builder.Services.AddSignalR(options => +{ + // Maximum message size (required) + options.MaximumReceiveMessageSize = 5242880; // 5 MB in bytes + + // Enable detailed errors in development + options.EnableDetailedErrors = builder.Environment.IsDevelopment(); + + // Timeout configurations + options.HandshakeTimeout = TimeSpan.FromSeconds(30); + options.KeepAliveInterval = TimeSpan.FromSeconds(15); + options.ClientTimeoutInterval = TimeSpan.FromSeconds(60); + + // Parallel hub invocations + options.MaximumParallelInvocationsPerClient = 10; + + // Streaming buffer size + options.StreamBufferCapacity = 10; +}); + +// Add memory cache for caching scenarios +builder.Services.AddMemoryCache(); + +// Add distributed cache for multi-server scenarios +builder.Services.AddDistributedMemoryCache(); + +builder.Services.AddRazorComponents() + .AddInteractiveServerComponents(); + +builder.Services.AddSyncfusionBlazor(); + +var app = builder.Build(); + +{% endhighlight %} +{% endtabs %} + +### Best practices + +* Set `MaximumReceiveMessageSize` based on expected data transfer sizes +* Balance between functionality and security because larger sizes increase memory usage and DoS risk +* Configure timeout values appropriate for network latency +* Enable detailed errors only in development environments +* Monitor SignalR connection metrics in production +* Consider implementing pagination or virtualization for very large datasets +* Use distributed caching for multi-server deployments + +### Performance considerations + +* Each active SignalR connection consumes server memory +* Larger message sizes require more server resources +* Consider implementing client-side pagination to reduce data transfer +* Use virtual scrolling for large grids and lists +* Implement lazy loading for large documents and images + +For production deployments, always balance functionality requirements with security and resource constraints. Extremely large message sizes can create denial-of-service vulnerabilities. + +## Issue 2: Namespace import issues + +**Symptom**: Compilation errors such as `The type or namespace name 'Syncfusion' could not be found` or `The name 'SfGrid' does not exist in the current context.` IntelliSense doesn't show components. + +**Root cause**: Required namespaces are not imported in `_Imports.razor` or component files. + +**Solution**: Add required namespaces to `~/Components/_Imports.razor` for global access or to individual component files. For the complete list of available packages, refer to the [Blazor NuGet packages](https://blazor.syncfusion.com/documentation/nuget-packages). + +### Global namespace import (recommended) + +{% tabs %} +{% highlight razor tabtitle="_Imports.razor" %} + +@using System.Net.Http +@using System.Net.Http.Json +@using Microsoft.AspNetCore.Components.Forms +@using Microsoft.AspNetCore.Components.Routing +@using Microsoft.AspNetCore.Components.Web +@using static Microsoft.AspNetCore.Components.Web.RenderMode +@using Microsoft.AspNetCore.Components.Web.Virtualization +@using Microsoft.JSInterop + +@using Syncfusion.Blazor + +// Add only the required Blazor component namespaces. Avoid importing unused component namespaces globally. +@using Syncfusion.Blazor.Grids +@using Syncfusion.Blazor.RichTextEditor +@using Syncfusion.Blazor.Charts +@using Syncfusion.Blazor.Schedule +@using Syncfusion.Blazor.TreeGrid +@using Syncfusion.Blazor.Diagram +@using Syncfusion.Blazor.Buttons + +@using YourApp +@using YourApp.Components + +{% endhighlight %} +{% endtabs %} + +### Component-specific namespace import + +If you prefer to import namespaces only where needed. + +{% tabs %} +{% highlight razor tabtitle="DataGridPage.razor" %} + +@page "/datagrid" +@rendermode InteractiveServer +@using Syncfusion.Blazor.Grids + +Data Grid + + + + + + + + +@code { + private List Orders { get; set; } = new() + { + new Order { OrderID = 1001, CustomerName = "Customer A" }, + new Order { OrderID = 1002, CustomerName = "Customer B" } + }; + + public class Order + { + public int OrderID { get; set; } + public string CustomerName { get; set; } = string.Empty; + } +} + +{% endhighlight %} +{% endtabs %} + +### Best practices + +* Add core `Syncfusion.Blazor` namespace globally in `_Imports.razor` +* Add component-specific namespaces globally if used across multiple pages +* Use component-level imports for rarely used components +* Organize imports alphabetically for better maintainability +* Remove unused namespace imports to reduce clutter + +The `_Imports.razor` file provides namespace imports to all Razor components in the same folder and subfolders. Place it at the root of your components folder for global access. + +## Issue 3: Incorrect TValue and field mapping in Blazor components + +**Symptom**: Components such as [Blazor DataGrid](https://www.syncfusion.com/blazor-components/blazor-datagrid), [Blazor DropDown List](https://www.syncfusion.com/blazor-components/blazor-dropdown-list), [Blazor MultiSelect Dropdown](https://www.syncfusion.com/blazor-components/blazor-multiselect-dropdown), [Blazor AutoComplete](https://www.syncfusion.com/blazor-components/blazor-autocomplete), [Blazor Numeric TextBox](https://www.syncfusion.com/blazor-components/blazor-numeric-textbox), [Blazor DatePicker](https://www.syncfusion.com/blazor-components/blazor-datepicker), or similar components render empty, do not bind correctly, or fail during selection, editing, filtering, or display. + +**Root cause**: The component `TValue`, item type, or field mappings such as `Field`, `Text`, and `Value` do not match the underlying data model. In some cases, the bound type also does not match the expected value format. + +**Solution**: Use strongly typed models and ensure that `TValue`, `DataSource`, and field mappings all refer to matching property types. + +### Step 1: Match `TValue` to the bound value type + +In [Blazor DropDown List](https://www.syncfusion.com/blazor-components/blazor-dropdown-list), ensure that `TValue` matches the type of the bound value and the corresponding value field in the data model. + +**Correct Mapping**: + +{% tabs %} +{% highlight razor tabtitle="Correct Mapping" %} + +@using Syncfusion.Blazor.DropDowns + + + + + +

    SelectedOrderId: @SelectedOrderId

    + +@code { + public int SelectedOrderId { get; set; } + + public List Orders { get; set; } = new() + { + new Order { OrderID = 1001, CustomerName = "Customer A" }, + new Order { OrderID = 1002, CustomerName = "Customer B" } + }; + + public class Order + { + public int OrderID { get; set; } + public string CustomerName { get; set; } = string.Empty; + } +} + +{% endhighlight %} +{% endtabs %} + +**Incorrect Mapping**: + +{% tabs %} +{% highlight razor tabtitle="Incorrect Mapping" %} + +@using Syncfusion.Blazor.DropDowns + + + + + +

    SelectedOrderCode: @SelectedOrderCode

    + +@code { + public string SelectedOrderCode { get; set; } = string.Empty; + + public List Orders { get; set; } = new() + { + new Order { OrderID = 1001, CustomerName = "Customer A" }, + new Order { OrderID = 1002, CustomerName = "Customer B" } + }; + + public class Order + { + public int OrderID { get; set; } + public string CustomerName { get; set; } = string.Empty; + } +} + +{% endhighlight %} +{% endtabs %} + +Here, `Value="OrderCode"` does not match any property in the data model, so the dropdown cannot resolve the selected value correctly. + +### Step 2: Map columns to real model properties + +In [Blazor DataGrid](https://www.syncfusion.com/blazor-components/blazor-datagrid), each GridColumn [Field](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.GridColumn.html#Syncfusion_Blazor_Grids_GridColumn_Field) value must match a public property on the model, including correct spelling and casing. + +{% tabs %} +{% highlight razor tabtitle="Blazor DataGrid Example" %} + +@using Syncfusion.Blazor.Grids + + + + + + + + + +@code { + public List Orders { get; set; } = new() + { + new Order { OrderID = 1001, CustomerName = "Customer A", OrderDate = DateTime.Today }, + new Order { OrderID = 1002, CustomerName = "Customer B", OrderDate = DateTime.Today.AddDays(-1) } + }; + + public class Order + { + public int OrderID { get; set; } + public string CustomerName { get; set; } = string.Empty; + public DateTime OrderDate { get; set; } + } +} + +{% endhighlight %} +{% endtabs %} + +**Common mistakes**: + +* Using a field name that does not exist in the model +* Typing the wrong casing, such as `Customername` instead of `CustomerName` +* Binding nested data without flattening the model first + +### Step 3: Use the correct value type for numeric and date inputs + +For [Blazor Numeric TextBox](https://www.syncfusion.com/blazor-components/blazor-numeric-textbox) and [Blazor DatePicker](https://www.syncfusion.com/blazor-components/blazor-datepicker), the bound property type must match the component's expected type (`TValue`). + +{% tabs %} +{% highlight razor tabtitle="Correct Input Mapping" %} + +@using Syncfusion.Blazor.Inputs +@using Syncfusion.Blazor.Calendars + + + + + +@code { + public decimal Freight { get; set; } = 125.50m; + public DateTime? OrderDate { get; set; } = DateTime.Today; +} + +{% endhighlight %} +{% endtabs %} + +### Step 4: Use the correct field names and value collection type + +In [Blazor MultiSelect Dropdown](https://www.syncfusion.com/blazor-components/blazor-multiselect-dropdown), the selected value collection type must match the item value type and corresponding field mapping. + +{% tabs %} +{% highlight razor tabtitle="MultiSelect Mapping" %} + +@using Syncfusion.Blazor.DropDowns + + + + + +@code { + public List SelectedEmployeeIds { get; set; } = new(); + + public List Employees { get; set; } = new() + { + new Employee { EmployeeId = 1, EmployeeName = "Anne" }, + new Employee { EmployeeId = 2, EmployeeName = "Ben" } + }; + + public class Employee + { + public int EmployeeId { get; set; } + public string EmployeeName { get; set; } = string.Empty; + } +} + +{% endhighlight %} +{% endtabs %} + +### Best practices + +* Set `TValue` to the exact type used by the bound value +* Use `nameof(...)` for grid field names to avoid spelling mistakes +* Keep data models strongly typed and consistent +* Use nullable types where the value can be empty, such as `int?` or `DateTime?` +* Do not bind a string field to a numeric value field +* Verify `Text` and `Value` mappings before testing dropdown components +* Flatten complex data models when a component does not support nested field paths + +### Common mapping errors + +| Component | Common Error | Correct Approach | +|-----------|--------------|------------------| +| [Blazor DataGrid](https://www.syncfusion.com/blazor-components/blazor-datagrid) | `Field="Customer"` when model has `CustomerName` | Use the exact property name | +| [Blazor DropDown List](https://www.syncfusion.com/blazor-components/blazor-dropdown-list) | `TValue="string"` with `Value="OrderID"` where `OrderID` is `int` | Make `TValue="int"` or change the value field | +| [Blazor Numeric TextBox](https://www.syncfusion.com/blazor-components/blazor-numeric-textbox) | Binding `string` to a numeric control | Use `int`, `decimal`, or `double` | +| [Blazor DatePicker](https://www.syncfusion.com/blazor-components/blazor-datepicker) | Binding `string` instead of `DateTime?` | Bind a date type | +| [Blazor MultiSelect Dropdown](https://www.syncfusion.com/blazor-components/blazor-multiselect-dropdown) | Mismatch between selected value collection and item value type | Use a matching collection type, such as `List` | + +This issue is usually a data-model mismatch, not a Syncfusion defect. In most cases, correcting the type mapping resolves the problem immediately. + +## Common error messages and solutions + +| Error Message | Likely Cause | Solution | +|---------------|-------------|----------| +| `The type or namespace name 'Syncfusion' could not be found` | Missing namespace import | Add `@using Syncfusion.Blazor` (and component namespaces as needed) to `_Imports.razor` | +| `Connection disconnected with error` | SignalR message size limit or timeout | Increase `options.MaximumReceiveMessageSize` and adjust SignalR timeouts in Program.cs. Consider using paging/virtualization or chunked transfers | \ No newline at end of file diff --git a/blazor/common/how-to/package-management-issues.md b/blazor/common/how-to/package-management-issues.md new file mode 100644 index 0000000000..f766eda96e --- /dev/null +++ b/blazor/common/how-to/package-management-issues.md @@ -0,0 +1,325 @@ +--- +layout: post +title: Resolving NuGet Package Management Issues in Blazor | Syncfusion® +description: Guide to resolving Blazor package management issues including NuGet conflicts, version mismatches, and dependency management +platform: Blazor +control: Common +documentation: ug +--- + +# Resolving NuGet Package Management Issues in Blazor + +This guide explains how to resolve common NuGet package management issues when building Blazor applications with **[Blazor components](https://www.syncfusion.com/blazor-components)**. Proper package management is essential for maintainable, efficient, and error-free applications. + +Common package management issues relate to: + +* Choosing between comprehensive and individual packages +* Avoiding duplicate package references +* Maintaining version consistency across packages +* Managing package dependencies in multi-project solutions + +N> This guide is intended for Blazor components version 33.2.3 or later. For supported .NET and Blazor package release combinations, see [Version compatibility for Blazor components](https://blazor.syncfusion.com/documentation/common/how-to/version-compatibility). + +## Issue 1: Installing redundant NuGet packages + +**Symptom**: Builds fail with ambiguous-call or duplicate-type errors when calling APIs, for example: + +{% tabs %} +{% highlight text tabtitle="Error Message" %} + +error CS0121: The call is ambiguous between the following methods or properties: +'Syncfusion.Blazor.SyncfusionBlazor.AddSyncfusionBlazor(...) [path\to\Syncfusion.Blazor.Core.dll]' +and 'Syncfusion.Blazor.SyncfusionBlazor.AddSyncfusionBlazor(...) [path\to\Syncfusion.Blazor.dll]' + +{% endhighlight %} +{% endtabs %} + +**Root cause**: The project references both the all-in-one package ([Syncfusion.Blazor](https://www.nuget.org/packages/Syncfusion.Blazor)) and one or more individual component packages (for example, [Syncfusion.Blazor.Grid](https://www.nuget.org/packages/Syncfusion.Blazor.Grid) or [Syncfusion.Blazor.Charts](https://www.nuget.org/packages/Syncfusion.Blazor.Charts)). These packages expose the same public types from different assemblies, producing duplicate type definitions and ambiguous method overloads. The compiler therefore reports ambiguous-call or duplicate-type errors. + +**Solution**: Use only the individual component packages that your application requires. The comprehensive [Syncfusion.Blazor](https://www.nuget.org/packages/Syncfusion.Blazor) package is not recommended for any application and should not be used. + +### Recommended package strategy + +Install only the specific component packages your application uses. This is the recommended approach for all projects. + +{% tabs %} +{% highlight bash tabtitle=".NET CLI" %} + +dotnet add package Syncfusion.Blazor.Grid -v {{ site.releaseversion }} +dotnet add package Syncfusion.Blazor.Calendars -v {{ site.releaseversion }} +dotnet add package Syncfusion.Blazor.Charts -v {{ site.releaseversion }} +dotnet add package Syncfusion.Blazor.Themes -v {{ site.releaseversion }} + +{% endhighlight %} +{% endtabs %} + +**Benefits**: + +* Smaller deployment size +* Faster build and restore times +* Clear dependency tracking +* Reduced licensing footprint for production deployments + +### Best practices + +* Do not use the [Syncfusion.Blazor](https://www.nuget.org/packages/Syncfusion.Blazor) package in your application +* Install only the specific component packages required by the application +* Audit your `.csproj` file regularly to identify redundant packages +* Document your package strategy in team guidelines + +### How to check for redundancy + +To check for redundant packages, inspect your project's `.csproj` file for duplicate or overlapping `` entries. + +{% tabs %} +{% highlight xml tabtitle="Incorrect setup" %} + + + ... + + + + + + + +{% endhighlight %} +{% highlight xml tabtitle="Recommended setup" %} + + + ... + + + + + + + + + +{% endhighlight %} +{% endtabs %} + +### To clean up redundant packages + +{% tabs %} +{% highlight bash tabtitle=".NET CLI" %} + +# Remove the comprehensive package if it is present +dotnet remove package Syncfusion.Blazor + +# Restore packages after cleanup +dotnet restore + +{% endhighlight %} +{% endtabs %} + +The [Syncfusion.Blazor.Themes](https://www.nuget.org/packages/Syncfusion.Blazor.Themes) package should always be installed separately, as it only contains theme stylesheets. + +## Issue 2: Duplicate package references + +**Symptom**: Build warnings such as `Detected package downgrade`, `Duplicate 'PackageReference' items found` or `Version conflict detected` or unpredictable runtime behavior where component features work inconsistently. These issues can also cause deployment problems due to assembly version conflicts and may lead to potential runtime exceptions. + +**Root cause**: The same NuGet package is referenced multiple times with different versions, either directly in the project file or transitively through dependencies. + +**Solution**: Identify and consolidate all package references to use a single version. For supported version combinations, see [Version compatibility for Blazor components](https://blazor.syncfusion.com/documentation/common/how-to/version-compatibility). + +### Step 1: Identify duplicate references + +Run the following command to analyze your project dependencies. + +{% tabs %} +{% highlight bash tabtitle=".NET CLI" %} + +dotnet list package --include-transitive + +{% endhighlight %} +{% endtabs %} + +This command shows all packages, including transitive dependencies, helping you spot version conflicts. + +### Step 2: Inspect project file + +Check your `.csproj` file for duplicate entries. + +{% tabs %} +{% highlight xml tabtitle="YourApp.csproj" %} + + + + + + + + + + + + +{% endhighlight %} +{% endtabs %} + +### Step 3: Consolidate versions + +Remove duplicate entries and ensure all Blazor packages use the same version. + +{% tabs %} +{% highlight xml tabtitle="YourApp.csproj" %} + + + + + + + + + + + +{% endhighlight %} +{% endtabs %} + +### Step 4: Use Central Package Management + +Use [Central Package Management (CPM)](https://learn.microsoft.com/en-us/nuget/consume-packages/central-package-management) for solution-wide version consistency. This approach is recommended for solutions with multiple projects. + +Create a `Directory.Packages.props` file in your solution root. + +{% tabs %} +{% highlight xml tabtitle="Directory.Packages.props" %} + + + + true + + + + + + + + + + + +{% endhighlight %} +{% endtabs %} + +Then update your project files to reference packages without versions. + +{% tabs %} +{% highlight xml tabtitle="YourApp.csproj" %} + + + + + + + + + +{% endhighlight %} +{% endtabs %} + +For single-project apps, consolidating package references directly in the `.csproj` file may be sufficient. + +### Best practices + +* Maintain consistent versions across all Blazor packages in your solution +* Use tooling like `dotnet list package --outdated` to identify version inconsistencies +* Implement Central Package Management for multi-project solutions +* Document your upgrade strategy and version policies +* Test thoroughly after consolidating package versions + +When upgrading Syncfusion packages, update **all Syncfusion packages** in your solution simultaneously to maintain version consistency. + +## Issue 3: Version mismatches across packages + +**Symptom**: Runtime exceptions such as `MissingMethodException`, `TypeLoadException`, or `FileLoadException`. Components may fail to initialize, throw errors during rendering, or exhibit unexpected behavior. These problems can lead to application crashes and difficult-to-diagnose runtime errors that only appear under specific conditions. + +**Root cause**: Different Blazor packages are installed with incompatible versions. For example, [Syncfusion.Blazor.Grid](https://www.nuget.org/packages/Syncfusion.Blazor.Grid) version 33.2.3 alongside [Syncfusion.Blazor.Calendars](https://www.nuget.org/packages/Syncfusion.Blazor.Calendars) version 32.1.19. + +**Solution**: Ensure all Blazor packages in your project use the **exact same version number**. For supported version combinations, see [Version compatibility for Blazor components](https://blazor.syncfusion.com/documentation/common/how-to/version-compatibility). + +### Step 1: Check current package versions + +{% tabs %} +{% highlight bash tabtitle=".NET CLI" %} + +dotnet list package + +{% endhighlight %} +{% endtabs %} + +Look for version discrepancies in the output. + +{% tabs %} +{% highlight bash tabtitle="Output" %} + +Project 'YourApp' has the following package references + + Top-level Package Requested Resolved + > Syncfusion.Blazor.Grid 33.2.3 33.2.3 + > Syncfusion.Blazor.Calendars 32.1.19 32.1.19 # Version mismatch + > Syncfusion.Blazor.Charts 33.2.3 33.2.3 + +{% endhighlight %} +{% endtabs %} + +### Step 2: Update all packages to matching version + +{% tabs %} +{% highlight bash tabtitle=".NET CLI" %} + +# Update individual packages to the latest version +dotnet add package Syncfusion.Blazor.Grid -v 33.2.3 +dotnet add package Syncfusion.Blazor.Calendars -v 33.2.3 +dotnet add package Syncfusion.Blazor.Charts -v 33.2.3 + +# Restore and rebuild +dotnet restore +dotnet build + +{% endhighlight %} +{% endtabs %} + +### Step 3: Verify version alignment + +{% tabs %} +{% highlight bash tabtitle=".NET CLI" %} + +dotnet list package + +{% endhighlight %} +{% endtabs %} + +All Blazor packages should now show the same version. + +{% tabs %} +{% highlight bash tabtitle="Output" %} + +Project 'YourApp' has the following package references + + Top-level Package Requested Resolved + > Syncfusion.Blazor.Grid 33.2.3 33.2.3 + > Syncfusion.Blazor.Calendars 33.2.3 33.2.3 + > Syncfusion.Blazor.Charts 33.2.3 33.2.3 + +{% endhighlight %} +{% endtabs %} + +### Best practices + +* Always upgrade all Blazor packages simultaneously to the same version +* Use automated tools or scripts to ensure version consistency across projects +* Review release notes before upgrading to understand breaking changes +* Test critical functionality after version updates + +### Common version mismatch scenarios + +* Copying component code from older projects without updating package versions +* Partial upgrades where only some packages are updated +* Adding new components from different version documentation examples +* Team members using different NuGet package sources with cached older versions + +Version mismatches are a leading cause of production issues. Implement CI/CD checks to validate version consistency before deployment. \ No newline at end of file diff --git a/blazor/common/integration/blazor-with-github-codespaces.md b/blazor/common/integration/blazor-with-github-codespaces.md new file mode 100644 index 0000000000..bdc5b1df92 --- /dev/null +++ b/blazor/common/integration/blazor-with-github-codespaces.md @@ -0,0 +1,335 @@ +--- +layout: post +title: Integrating Blazor DataGrid with GitHub Codespaces | Syncfusion +description: Step by step guide to integrate Blazor DataGrid in a Blazor Web App using GitHub Codespaces with development container setup and cloud based execution. +platform: Blazor +control: Common +documentation: ug +--- + +# Integrating Blazor DataGrid with GitHub Codespaces + +This article explains how to integrate the **[Blazor DataGrid](https://www.syncfusion.com/blazor-components/blazor-datagrid)** and run it seamlessly in **[GitHub Codespaces](https://docs.github.com/en/codespaces/about-codespaces/what-are-codespaces)**. + +GitHub Codespaces provides a cloud-based development environment that eliminates the need for local setup and enables instant development in Visual Studio Code directly in the browser. + +## Prerequisites + +Before getting started, ensure you have the following: + +* A [GitHub](https://github.com/) account +* Access to [GitHub Codespaces](https://docs.github.com/en/codespaces/about-codespaces/what-are-codespaces) + +## Configure a development container for .NET 10 and Blazor + +To run Blazor applications in GitHub Codespaces, configure a development container with the **[.NET 10 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/10.0)** and support for **ASP.NET Core and Blazor development**. + +### Prerequisites for dev container setup + +* A local [Git](https://git-scm.com/) client installed on your machine +* Your repository cloned locally or access to create files through the [GitHub web interface](https://docs.github.com/en/repositories/working-with-files/managing-files/creating-new-files) + +### Create the dev container configuration + +#### Step 1: Clone your repository + +Clone your GitHub repository to your local machine. + +{% tabs %} +{% highlight bash tabtitle="Terminal" %} + +git clone +cd + +{% endhighlight %} +{% endtabs %} + +You can also create files directly in GitHub by navigating to your repository and selecting **Add file → Create new file**. + +#### Step 2: Create the `.devcontainer` folder + +Create a folder named `.devcontainer` at the root level of your repository. + +{% tabs %} +{% highlight bash tabtitle="Terminal" %} + +mkdir .devcontainer + +{% endhighlight %} +{% endtabs %} + +#### Step 3: Add the `devcontainer.json` file + +Inside the `.devcontainer` folder, create a file named `devcontainer.json` and add the following configuration. GitHub Codespaces automatically applies the settings from this file when a codespace starts. Add it to your repository before launching Codespaces so the environment is configured correctly. + +{% tabs %} +{% highlight json tabtitle=".devcontainer/devcontainer.json" %} + +{ + "name": "Blazor (.NET 10) Codespaces Development Container", + "image": "mcr.microsoft.com/devcontainers/dotnet:10.0", + "features": { + "ghcr.io/devcontainers/features/github-cli:1": {} + }, + "customizations": { + "vscode": { + "extensions": [ + "ms-dotnettools.csharp", + "ms-dotnettools.csdevkit", + "ms-dotnettools.vscodeintellicode-csharp", + "ms-dotnettools.blazor-tools", + "ms-azuretools.vscode-docker", + "GitHub.codespaces" + ] + } + }, + "forwardPorts": [5000], + "portsAttributes": { + "5000": { + "label": "Blazor HTTP", + "onAutoForward": "openBrowser", + "requireLocalPort": false + } + }, + "postCreateCommand": "dotnet workload install wasm-tools", + "postStartCommand": "dotnet restore || true", + "updateContentCommand": "dotnet workload update", + "remoteUser": "vscode", + "remoteEnv": { + "DOTNET_SYSTEM_GLOBALIZATION_INVARIANT": "false", + "ASPNETCORE_ENVIRONMENT": "Development", + "ASPNETCORE_URLS": "http://0.0.0.0:5000", + "DOTNET_CLI_TELEMETRY_OPTOUT": "true" + }, + "waitFor": "postCreateCommand" +} + +{% endhighlight %} +{% endtabs %} + +#### Key configuration details + +* **Base image**: Uses the official .NET 10 development container image +* **Features**: Includes [GitHub CLI](https://cli.github.com/) for repository operations within Codespaces +* **VS Code extensions**: Installs [C# Dev Kit](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csdevkit), Blazor tools, and [Docker](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-docker) support automatically +* **Port forwarding**: Uses `forwardPorts` to expose the HTTP port (5000), enabling external access to the application running inside the Codespaces container +* **WebAssembly (WASM) tools**: Installs Blazor WebAssembly development tools via `workload install` +* **Environment variables**: Configures [.NET globalization](https://learn.microsoft.com/en-us/dotnet/core/extensions/globalization), development environment, and both protocol URLs +* **Post-create command**: Automatically restores NuGet packages and installs required workloads after container setup +* **Post-start restoration**: Runs `dotnet restore` on each container start, and the `|| true` ensures the container starts successfully even if restore produces non-critical warnings + +This configuration ensures your Codespaces environment is ready to build and run Blazor applications without any manual setup. + +#### Step 4: Commit and push to GitHub + +Commit the `.devcontainer` folder to your repository. + +{% tabs %} +{% highlight bash tabtitle="Terminal" %} + +git add .devcontainer/devcontainer.json +git commit -m "Add dev container configuration for Blazor development in GitHub Codespaces" +git push origin main + +{% endhighlight %} +{% endtabs %} + +## Launch GitHub Codespaces + +After adding the dev container configuration to your repository, launch GitHub Codespaces: + +1. Open your GitHub repository in the browser. +2. Click the **Code** button. +3. Select the **Codespaces** tab. +4. Click **Create codespace on main**. + +GitHub Codespaces automatically performs the following actions: + +* Provisions a cloud-based development environment +* Detects the `.devcontainer/devcontainer.json` configuration +* Installs and configures the .NET 10 development container +* Installs required VS Code extensions for [C#](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp), Blazor tools, [Docker](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-docker), and [GitHub CLI](https://cli.github.com/) +* Executes the post-create command to restore NuGet packages +* Installs **Blazor WebAssembly** workload tools +* Launches [Visual Studio Code](https://code.visualstudio.com/) in the browser + +After Codespaces finishes initializing, verify the setup: + +1. Open the terminal in Codespaces. +2. Run `dotnet --list-sdks` to confirm that the **[.NET 10 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/10.0)** is installed. +3. Run `dotnet workload list` to verify that the `wasm-tools` workload is present. +4. Check the terminal output for any errors from the post-create command. + +If the setup encounters errors, review the container logs or rebuild the codespace. + +## Create a Blazor Web App + +In the Codespaces root terminal, run the following commands to create a new **Blazor Web App (Interactive Server)**. + +{% tabs %} +{% highlight bash tabtitle="Terminal" %} + +dotnet new blazor -o BlazorApp --interactivity Server +cd BlazorApp + +{% endhighlight %} +{% endtabs %} + +## Install required NuGet packages + +Install the [Syncfusion.Blazor.Grid](https://www.nuget.org/packages/Syncfusion.Blazor.Grid/) and [Syncfusion.Blazor.Themes](https://www.nuget.org/packages/Syncfusion.Blazor.Themes/) NuGet packages. All Syncfusion Blazor packages are available on [nuget.org](https://www.nuget.org/packages?q=syncfusion.blazor). See the [NuGet packages](https://blazor.syncfusion.com/documentation/nuget-packages) topic for details. + +{% tabs %} +{% highlight bash tabtitle="Terminal" %} + +dotnet add package Syncfusion.Blazor.Grid -v {{ site.releaseversion }} +dotnet add package Syncfusion.Blazor.Themes -v {{ site.releaseversion }} + +{% endhighlight %} +{% endtabs %} + +## Add required namespaces + +After the packages are installed, open the `~/_Imports.razor` file in Blazor Web App and import the `Syncfusion.Blazor` and `Syncfusion.Blazor.Grids` namespaces. + +{% tabs %} +{% highlight razor tabtitle="_Imports.razor" %} + +@using Syncfusion.Blazor +@using Syncfusion.Blazor.Grids + +{% endhighlight %} +{% endtabs %} + +## Register Blazor service + +Open the `~/Program.cs` file in Blazor Web App and register the Blazor service to enable [Blazor components](https://www.syncfusion.com/blazor-components) in the application. + +{% tabs %} +{% highlight C# tabtitle="Program.cs" hl_lines="1 9" %} + +using Syncfusion.Blazor; + +var builder = WebApplication.CreateBuilder(args); + +builder.Services.AddRazorComponents() + .AddInteractiveServerComponents(); + +// Register Blazor service +builder.Services.AddSyncfusionBlazor(); + +var app = builder.Build(); + +{% endhighlight %} +{% endtabs %} + +## Add stylesheet and script resources + +The theme stylesheet and script can be accessed from NuGet through [Static Web Assets](https://blazor.syncfusion.com/documentation/appearance/themes#static-web-assets). Include the [stylesheet](https://blazor.syncfusion.com/documentation/appearance/themes) and [script references](https://blazor.syncfusion.com/documentation/common/adding-script-references) in the `~/App.razor` file. + +{% tabs %} +{% highlight html tabtitle="App.razor" %} + + + ... + + + + + ... + + + +{% endhighlight %} +{% endtabs %} + +## Configure render mode (Server) + +For Server render mode, if your app's interactivity location is set to `Per page/component`, add the following directive at the top of each `~/Pages/*.razor` file that requires interactive Server components. + +**Per-page directive (Server)** + +{% tabs %} +{% highlight razor %} + +@rendermode InteractiveServer + +{% endhighlight %} +{% endtabs %} + +## Add Blazor DataGrid component + +Open a Razor file located in the `~/Pages/*.razor` (for example, `Home.razor`) and add the [Blazor DataGrid](https://www.syncfusion.com/blazor-components/blazor-datagrid) component inside the razor file. + +{% tabs %} +{% highlight razor tabtitle="Home.razor" %} + +@page "/" +@rendermode InteractiveServer + +

    Blazor DataGrid in Codespaces

    + + + +@code { + public List Orders { get; set; } = new List(); + + protected override void OnInitialized() + { + var customers = new string[] { "James Hopper", "Michael Smith", "Sarah Johnson", "Robert Davis", "Emily Wilson" }; + var cities = new string[] { "New York", "Los Angeles", "Chicago", "Houston", "Phoenix" }; + var rng = new Random(); + Orders = Enumerable.Range(1, 10).Select(x => new Order() + { + OrderID = 1000 + x, + CustomerName = customers[rng.Next(customers.Length)], + ShipCity = cities[rng.Next(cities.Length)], + Freight = Math.Round(10.5 + (x * 7.3), 2), + OrderDate = DateTime.Now.AddDays(-x), + }).ToList(); + } + + public class Order { + public int? OrderID { get; set; } + public string CustomerName { get; set; } = string.Empty; + public string ShipCity { get; set; } = string.Empty; + public DateTime? OrderDate { get; set; } + public double? Freight { get; set; } + } +} + +{% endhighlight %} +{% endtabs %} + +## Run the application in Codespaces + +In the Codespaces terminal, run: + +{% tabs %} +{% highlight bash tabtitle="Terminal" %} + +dotnet run --urls=http://0.0.0.0:5000 + +{% endhighlight %} +{% endtabs %} + +### Access the application + +After running: + +1. Codespaces automatically detects the running ports. +2. Open the **Ports** panel in the VS Code bottom panel. +3. Click **Open in Browser** on the HTTP port (5000) for the best experience. + +The Blazor application loads with the DataGrid displaying 10 order records. The grid is fully interactive and runs within the Codespaces browser environment. + +![Blazor DataGrid with Github Codespaces](images/datagrid-with-codespace.webp) + +N> [View Sample in GitHub](https://github.com/SyncfusionExamples/blazor-codespaces-integration) + +## See also + +* [Getting Started with Blazor DataGrid in Blazor Web App](https://blazor.syncfusion.com/documentation/datagrid/getting-started-with-web-app) +* [Integrating Blazor DataGrid with PDF Viewer](https://blazor.syncfusion.com/documentation/common/integration/blazor-with-pdf-viewer) +* [Integrating Blazor DataGrid with Spreadsheet](https://blazor.syncfusion.com/documentation/common/integration/blazor-grid-with-spreadsheet) +* [Integrating Blazor DataGrid with Bold Report Viewer](https://blazor.syncfusion.com/documentation/common/integration/blazor-datagrid-boldreports) \ No newline at end of file diff --git a/blazor/common/migration/webform-to-blazor-migration.md b/blazor/common/migration/webform-to-blazor-migration.md new file mode 100644 index 0000000000..7740b36a88 --- /dev/null +++ b/blazor/common/migration/webform-to-blazor-migration.md @@ -0,0 +1,437 @@ +--- +layout: post +title: Migrate ASP.NET Web Forms Controls to Blazor Components | Syncfusion +description: Step-by-step guide to migrate ASP.NET Web Forms controls including DataGrid, Scheduler, and Rich Text Editor to Blazor components targeting .NET 8 or later. +platform: Blazor +control: Common +documentation: ug +--- + +# Migrate ASP.NET Web Forms Controls to Blazor Components + +Migrating enterprise applications from [ASP.NET Web Forms](https://learn.microsoft.com/en-us/aspnet/web-forms/) to [Blazor](https://learn.microsoft.com/en-us/aspnet/core/blazor/?view=aspnetcore-10.0) represents a significant architectural shift from a page centric, postback based framework to a modern, component driven framework built on .NET. This guide provides a structured, step-by-step migration approach for [ASP.NET Web Forms controls](https://help.syncfusion.com/aspnet/overview) to their corresponding [Blazor components](https://blazor.syncfusion.com/documentation/introduction). + +## Why migrate from Web Forms to Blazor? + +[ASP.NET Web Forms](https://learn.microsoft.com/en-us/aspnet/web-forms/) follows a **server-side page model** that uses ViewState, postback, and a tightly coupled page lifecycle to process requests and maintain UI state across interactions. + +[Blazor](https://learn.microsoft.com/en-us/aspnet/core/blazor/?view=aspnetcore-10.0) uses a component based architecture with reusable Razor components and **event driven UI updates**, where user interactions trigger handlers that refresh the UI without full page reloads. This modern approach improves maintainability, scalability, and testability, making Blazor the preferred choice for migrating and modernizing Web Forms applications. + +| Aspect | Web Forms | Blazor | +| --- | --- | --- | +| Execution model | Server centric (page postback) | Blazor Server (SignalR) or Blazor WebAssembly | +| Hosting & deployment | IIS hosted only | Cloud, containers, IIS, or static hosting | +| UI definition | Separate markup and code-behind (`.aspx`, `.aspx.cs`) | Component based (`.razor` with optional `.razor.cs`) | +| Lifecycle model | `Page_Load`, postback events, `Page_Unload` | `OnInitialized{Async}`, `OnParametersSet{Async}`, `OnAfterRender{Async}`, `Dispose` | +| State management | ViewState (hidden fields, page level) | Component state (in-memory, persisted per connection in Blazor Server) | +| User interaction | Full or partial postback (page reload) | Event driven UI updates (real-time in Blazor Server via SignalR) | +| Event handling | Server callbacks (AutoPostBack) | `EventCallback` and delegates | +| Dependency injection | Limited or manual | Built-in with `IServiceCollection` | +| Navigation model | Page based navigation (`.aspx`) | SPA style routing using `@page` | +| Application updates | Requires restart for assembly changes | Blazor Server: immediate; WebAssembly: versioned deployment | + +## Prerequisites for Blazor + +* [.NET 8 SDK or later](https://dotnet.microsoft.com/en-us/download/dotnet) +* [Visual Studio](https://visualstudio.microsoft.com/downloads/) 2022 or later or [Visual Studio Code](https://code.visualstudio.com/) with [C# Dev Kit](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csdevkit) extension + +## Project structure comparison + +[ASP.NET Web Forms](https://learn.microsoft.com/en-us/aspnet/web-forms/) and [Blazor](https://learn.microsoft.com/en-us/aspnet/core/blazor/?view=aspnetcore-10.0) Web Apps follow different application architectures. The following table maps common Web Forms artifacts to their Blazor equivalents and describes their roles in a Blazor Web App. + +| Web Forms Artifact | Blazor Web App Equivalent | Description | +| --- | --- | --- | +| `Default.aspx` | `Components/Pages/Home.razor` | Represents the UI page and route entry point | +| `Default.aspx.cs` | `@code {}` block or `.razor.cs` file | Contains UI logic and event handling | +| `Global.asax` | `Program.cs` | Configures application startup, services, and middleware | +| `web.config` | `appsettings.json` | Stores configuration and environment settings | +| Master Page (`Site.Master`) | `MainLayout.razor`, `App.razor` | Defines shared layout and structure across pages and defines script and style | +| ViewState | Component state (fields/properties) | Maintains UI state in memory instead of hidden fields | +| Routing (`*.aspx`) | `@page` directive in `.razor` files | Enables route based navigation | +| Session / Application state | Scoped / Singleton services | Manages shared application state | + +## Migrating components from Web Forms to Blazor + +Create a [Blazor](https://learn.microsoft.com/en-us/aspnet/core/blazor/?view=aspnetcore-10.0) project using one of the following getting started guides. + +* [Getting Started with Blazor Web App](https://blazor.syncfusion.com/documentation/getting-started/blazor-web-app) +* [Getting Started with Blazor Server App](https://blazor.syncfusion.com/documentation/getting-started/blazor-server-side-visual-studio) +* [Getting Started with Blazor WebAssembly App](https://blazor.syncfusion.com/documentation/getting-started/blazor-webassembly-app) + +The following shared setup applies to all components and covers the common configuration required before proceeding to the [component specific migration steps](#component-specific-migration-steps). + +### Package installation + +In [ASP.NET Web Forms](https://learn.microsoft.com/en-us/aspnet/web-forms/) applications, components are typically installed using a single package, [Syncfusion.AspNet](https://www.nuget.org/packages/Syncfusion.AspNet). + +In [Blazor](https://learn.microsoft.com/en-us/aspnet/core/blazor/?view=aspnetcore-10.0) applications, using individual component packages improves performance and reduces application size. For the complete list of available packages, refer to the [Blazor NuGet packages](https://blazor.syncfusion.com/documentation/nuget-packages). + +Additionally, install the [Syncfusion.Blazor.Themes](https://www.nuget.org/packages/Syncfusion.Blazor.Themes) NuGet package for styling support. + +### Service registration + +[ASP.NET Web Forms](https://learn.microsoft.com/en-us/aspnet/web-forms/) initializes controls automatically as part of the page lifecycle, without requiring explicit service registration. + +[Blazor](https://learn.microsoft.com/en-us/aspnet/core/blazor/?view=aspnetcore-10.0) uses dependency injection (DI), where components must be registered in the service container to enable required functionality such as rendering and interaction. + +In the `Program.cs` file, add the following namespace and register the required services. + +{% tabs %} +{% highlight csharp tabtitle="Program.cs" %} + +using Syncfusion.Blazor; +... +var builder = WebApplication.CreateBuilder(args); +builder.Services.AddRazorComponents() + .AddInteractiveServerComponents(); +builder.Services.AddSyncfusionBlazor(); // Register Blazor services +var app = builder.Build(); +... + +{% endhighlight %} +{% endtabs %} + +### Add required namespaces + +After packages are installed and services are registered, import the required namespaces in the `_Imports.razor` file. + +{% tabs %} +{% highlight razor tabtitle="_Imports.razor" %} + +@using Syncfusion.Blazor +@using Syncfusion.Blazor.Grids +@using Syncfusion.Blazor.Schedule +@using Syncfusion.Blazor.RichTextEditor + +{% endhighlight %} +{% endtabs %} + +The above lists the namespaces for all components covered in this guide. Import only the namespaces required for the components you use. + +### Theme and script configuration + +**Web Forms approach** + +Scripts and styles are added manually in individual `.aspx` pages or `Site.Master` pages. + +{% tabs %} +{% highlight html tabtitle=".aspx" %} + + + + + + + +{% endhighlight %} +{% endtabs %} + +**Blazor equivalent** + +The theme stylesheet and script can be accessed from NuGet through [Static Web Assets](https://blazor.syncfusion.com/documentation/appearance/themes#static-web-assets). Include the [stylesheet](https://blazor.syncfusion.com/documentation/appearance/themes) and [script references](https://blazor.syncfusion.com/documentation/common/adding-script-references) in the **App.razor** file. + +{% tabs %} +{% highlight html tabtitle="App.razor" %} + + + ... + + + ... + + + ... + + + ... + + +{% endhighlight %} +{% endtabs %} + +## Component specific migration steps + +### Migrate to Blazor DataGrid component + +**ASP.NET Web Forms Grid** is a traditional control for displaying and managing tabular data in web applications while [Blazor DataGrid](https://www.syncfusion.com/blazor-components/blazor-datagrid) is a modern component designed to provide a faster, more interactive, and responsive user experience. + +For additional details, refer to the [Blazor DataGrid getting started guide](https://blazor.syncfusion.com/documentation/datagrid/getting-started-with-server-app) and [Web Forms DataGrid getting started guide](https://help.syncfusion.com/aspnet/grid/getting-started). + +| Aspect | Web Forms (`ej:Grid`) | Blazor (`SfGrid / SfGrid`) | +| --- | --- | ---| +| Package (NuGet) | [Syncfusion.AspNet](https://www.nuget.org/packages/Syncfusion.AspNet) | [Syncfusion.Blazor.Grid](https://www.nuget.org/packages/Syncfusion.Blazor.Grid) | +| Namespace | `<%@ Register Assembly="Syncfusion.EJ.Web" %>` | `@using Syncfusion.Blazor.Grids` | +| Component declaration | `` | `` / `` | +| Data binding | [DataSource](https://help.syncfusion.com/cr/aspnet/Syncfusion.JavaScript.Models.GridProperties.html#Syncfusion_JavaScript_Models_GridProperties_DataSource) property set in `Page_Load` or callbacks | [DataSource](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_DataSource) property bound during component initialization | +| Collection type | `DataTable`, `IEnumerable`, server managed collections | `List` / `IEnumerable` | +| Columns | [Columns](https://help.syncfusion.com/cr/aspnet/Syncfusion.JavaScript.Models.GridProperties.html#Syncfusion_JavaScript_Models_GridProperties_Columns) property defined using `` | [Columns](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_Columns) property defined by using `` | +| Editing & API | [EditSettings](https://help.syncfusion.com/cr/aspnet/Syncfusion.JavaScript.Models.GridProperties.html#Syncfusion_JavaScript_Models_GridProperties_EditSettings) | [GridEditSettings](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.GridEditSettings.html), [GridEvents](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.GridEvents-1.html), `@ref` async APIs | +| Events & commands | Server events (postback / AJAX callbacks) | `EventCallback` based async handlers | +| Paging / virtualization API | [AllowPaging](https://help.syncfusion.com/cr/aspnet/Syncfusion.JavaScript.Models.GridProperties.html#Syncfusion_JavaScript_Models_GridProperties_AllowPaging), [ScrollSettings](https://help.syncfusion.com/cr/aspnet/Syncfusion.JavaScript.Models.GridProperties.html#Syncfusion_JavaScript_Models_GridProperties_ScrollSettings) | [AllowPaging](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_AllowPaging), [GridPageSettings](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.GridPageSettings.html), [EnableVirtualization](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_EnableVirtualization) | +| Filtering API | [AllowFiltering](https://help.syncfusion.com/cr/aspnet/Syncfusion.JavaScript.Models.GridProperties.html#Syncfusion_JavaScript_Models_GridProperties_AllowFiltering) | [AllowFiltering](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_AllowFiltering) | +| Grouping API | [AllowGrouping](https://help.syncfusion.com/cr/aspnet/Syncfusion.JavaScript.Models.GridProperties.html#Syncfusion_JavaScript_Models_GridProperties_AllowGrouping) | [AllowGrouping](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_AllowGrouping)| +| Lifecycle & refs | `Page_Load`, control IDs (`ID`) | `OnInitialized{Async}`, DI, `@ref` and async methods | + +#### Component configuration for DataGrid + +**Web Forms approach** + +The Grid control for ASP.NET is an efficient display engine for tabular data by defining [Columns](https://help.syncfusion.com/cr/aspnet/Syncfusion.JavaScript.Models.GridProperties.html#Syncfusion_JavaScript_Models_GridProperties_Columns) and linking them to `Fields` in a [DataSource](https://help.syncfusion.com/cr/aspnet/Syncfusion.JavaScript.Models.GridProperties.html#Syncfusion_JavaScript_Models_GridProperties_DataSource) property. In the example, a list of people is created and assigned to the Grid, which then automatically displays the data as rows and columns. + +{% tabs %} +{% highlight html tabtitle="Default.aspx" %} + + + + + + + + + +{% endhighlight %} + +{% highlight c# tabtitle="Default.aspx.cs" %} + +using System.Web.UI; +namespace WebFormsGrid +{ + public partial class _Default : Page + { + protected void Page_Load(object sender, EventArgs e) + { + List Persons = new List + { + new Person() { FirstName = "John", LastName = "Beckett", Email = "john@syncfusion.com" }, + new Person() { FirstName = "Ben", LastName = "Beckett", Email = "ben@syncfusion.com" }, + new Person() { FirstName = "Andrew", LastName = "Beckett", Email = "andrew@syncfusion.com" } + }; + this.Grid.DataSource = Persons; + } + } + public class Person + { + public string FirstName { get; set; } + public string LastName { get; set; } + public string Email { get; set; } + } +} + +{% endhighlight %} +{% endtabs %} + +**Blazor equivalent** + +The [Blazor DataGrid](https://www.syncfusion.com/blazor-components/blazor-datagrid) component is declared in Razor markup and binds data directly to a component property using the [DataSource](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_DataSource) property. + +{% tabs %} +{% highlight razor tabtitle="Home.razor" %} + + + + + + + + + +@code { + private List Persons = new() + { + new Person { FirstName = "John", LastName = "Beckett", Email = "john@syncfusion.com" }, + new Person { FirstName = "Ben", LastName = "Beckett", Email = "ben@syncfusion.com" }, + new Person { FirstName = "Andrew", LastName = "Beckett", Email = "andrew@syncfusion.com" } + }; + + public class Person + { + public string? FirstName { get; set; } + public string? LastName { get; set; } + public string? Email { get; set; } + } +} + +{% endhighlight %} +{% endtabs %} + +### Migrate to Blazor Scheduler component + +**ASP.NET Web Forms Scheduler** is used to organize and manage events across different calendar views in web applications, while [Blazor Scheduler](https://www.syncfusion.com/blazor-components/blazor-scheduler) is a modern component that offers a more dynamic and user friendly way to handle appointments and scheduling. + +For additional details, refer to the [Blazor Scheduler getting started guide](https://blazor.syncfusion.com/documentation/scheduler/getting-started-with-server-app) and [Web Forms Scheduler getting started guide](https://help.syncfusion.com/aspnet/schedule/getting-started). + +| Aspect | Web Forms (`ej:Schedule`) | Blazor (`SfSchedule`) | +| --- | --- | --- | +| Package (NuGet) | [Syncfusion.AspNet](https://www.nuget.org/packages/Syncfusion.AspNet) | [Syncfusion.Blazor.Schedule](https://www.nuget.org/packages/Syncfusion.Blazor.Schedule) | +| Namespace | `<%@ Register Assembly="Syncfusion.EJ.Web" %>` | `@using Syncfusion.Blazor.Schedule` | +| Component declaration | `` | `` | +| Data binding API | [DataSource](https://help.syncfusion.com/cr/aspnet/Syncfusion.JavaScript.Models.ScheduleFields.html#Syncfusion_JavaScript_Models_ScheduleFields_DataSource) set during `Page_Load` or callbacks | `DataSource="@..."` via [ScheduleEventSettings.DataSource](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Schedule.ScheduleEventSettings-1.html#Syncfusion_Blazor_Schedule_ScheduleEventSettings_1_DataSource) | +| Appointment model API | [AppointmentSettings](https://help.syncfusion.com/cr/aspnet/Syncfusion.JavaScript.Models.ScheduleProperties.html#Syncfusion_JavaScript_Models_ScheduleProperties_AppointmentSettings) | [ScheduleEventSettings](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Schedule.ScheduleEventSettings-1.html) | +| Views configuration | [CurrentView](https://help.syncfusion.com/cr/aspnet/Syncfusion.JavaScript.Models.ScheduleProperties.html#Syncfusion_JavaScript_Models_ScheduleProperties_CurrentView) property | [ScheduleViews](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Schedule.ScheduleView.html) collection | +| Lifecycle & refs | `Page_Load`, control `ID` | `OnInitialized{Async}`, DI, `@ref` async APIs | + +#### Component configuration for Scheduler + +**Web Forms approach** + +The **Scheduler** is an event calendar that manages the list of various activities (events/appointments) in different available views (day, week, workweek, month and agenda) for various resources. It is simply a server-side wrapper of JS Scheduler component and all the features of JS platform are applicable in ASP Scheduler too. + +{% tabs %} +{% highlight html tabtitle="Default.aspx" %} + + + + +{% endhighlight %} + +{% highlight c# tabtitle="Default.aspx.cs" %} + +using System; +using System.Collections.Generic; +using System.Web.UI; + +namespace WebFormsScheduler +{ + public partial class _Default : Page + { + protected void Page_Load(object sender, EventArgs e) + { + Schedule1.AppointmentSettings.DataSource = new List + { + new Appointment + { + Id = 1, + Subject = "Meeting", + StartTime = DateTime.Now, + EndTime = DateTime.Now.AddHours(1) + } + }; + Schedule1.AppointmentSettings.Id = "Id"; + Schedule1.AppointmentSettings.Subject = "Subject"; + Schedule1.AppointmentSettings.StartTime = "StartTime"; + Schedule1.AppointmentSettings.EndTime = "EndTime"; + } + } + + public class Appointment + { + public int Id { get; set; } + public string Subject { get; set; } + public DateTime StartTime { get; set; } + public DateTime EndTime { get; set; } + } +} + +{% endhighlight %} +{% endtabs %} + +**Blazor equivalent** + +The [Blazor Scheduler](https://www.syncfusion.com/blazor-components/blazor-scheduler) component is declared in Razor markup, where views are configured using child components, and appointment data is supplied through the [ScheduleEventSettings.Datasource](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Schedule.ScheduleEventSettings-1.html) property. + +{% tabs %} +{% highlight razor tabtitle="Schedule.razor" %} + + + + + + + + + + +@code { + private List Meetings = new() + { + new Meeting + { + Id = 1, + Subject = "Meeting", + StartTime = DateTime.Now, + EndTime = DateTime.Now.AddHours(1) + } + }; + + public class Meeting + { + public int Id { get; set; } + public string Subject { get; set; } = string.Empty; + public DateTime StartTime { get; set; } + public DateTime EndTime { get; set; } + } +} + +{% endhighlight %} +{% endtabs %} + +N> The event class (`Meeting` in this example) property names match the Scheduler's default field mappings. Alternatively, you can add an explicit [Fields](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Schedule.ScheduleField.html) configuration in `ScheduleEventSettings` to map custom property names. + +### Migrate to Blazor Rich Text Editor component + +**ASP.ET Web Forms Rich Text Editor** is a component used for creating and formatting content such as text, images, tables, and links with various editing tools. [Blazor Rich Text Editor](https://www.syncfusion.com/blazor-components/blazor-rich-text-editor) is a modern component that offers a more dynamic and user-friendly way to create rich content with support for HTML, Markdown, and responsive design. + +For additional details, refer to the [Blazor Rich Text Editor getting started guide](https://blazor.syncfusion.com/documentation/rich-text-editor/getting-started-with-server-app) and [Web Forms Rich Text Editor getting started guide](https://help.syncfusion.com/aspnet/richtexteditor/getting-started). + +| Aspect | Web Forms (`ej:RTE`) | Blazor (`SfRichTextEditor`) | +| --- | --- | ---| +| Package (NuGet) | [Syncfusion.AspNet](https://www.nuget.org/packages/Syncfusion.AspNet) | [Syncfusion.Blazor.RichTextEditor](https://www.nuget.org/packages/Syncfusion.Blazor.RichTextEditor) | +| Namespace | ASPX: `<%@ Register Assembly="Syncfusion.EJ.Web" %>` | Razor: `@using Syncfusion.Blazor.RichTextEditor` | +| Component declaration | `` (ASPX) | `` (Razor) | +| Content binding | [Value](https://help.syncfusion.com/cr/aspnet/Syncfusion.JavaScript.Models.RTEproperties.html#Syncfusion_JavaScript_Models_RTEproperties_Value) property set during page lifecycle | [Value](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.RichTextEditor.SfRichTextEditor.html#Syncfusion_Blazor_RichTextEditor_SfRichTextEditor_Value) / `@bind-Value` bound to component state | +| Toolbar configuration | [ToolsList](https://help.syncfusion.com/cr/aspnet/Syncfusion.JavaScript.Models.RTEproperties.html#Syncfusion_JavaScript_Models_RTEproperties_ToolsList), [Tools](https://help.syncfusion.com/cr/aspnet/Syncfusion.JavaScript.Models.RTEproperties.html#Syncfusion_JavaScript_Models_RTEproperties_Tools) | [ToolbarSettings](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.RichTextEditor.RichTextEditorToolbarSettings.html) with predefined/custom items | +| Lifecycle & refs | `Page_Load`, control `ID` | `OnInitialized{Async}`, DI, `@ref` async APIs | + +#### Component configuration for Rich Text Editor + +**Web Forms approach** + +The Rich Text Editor content is defined directly within the markup using the `RTEContent` section, with content embedded as static HTML. + +{% tabs %} +{% highlight html tabtitle="Default.aspx" %} + + + +

    Welcome to Blazor Rich Text Editor

    +
    +
    + +{% endhighlight %} +{% endtabs %} + +**Blazor equivalent** + +The [Blazor Rich Text Editor](https://www.syncfusion.com/blazor-components/blazor-rich-text-editor) is implemented as a Razor component, where content is bound dynamically using the [Value](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.RichTextEditor.SfRichTextEditor.html#Syncfusion_Blazor_RichTextEditor_SfRichTextEditor_Value) property with two-way binding. + +{% tabs %} +{% highlight razor tabtitle="Editor.razor" %} + + + +@code { + private string? Content = "

    Welcome to Blazor Rich Text Editor

    "; +} + +{% endhighlight %} +{% endtabs %} + +## Run the application + +Press Ctrl+F5 (Windows) or +F5 (macOS) to launch the application. + +Alternatively, run the application using the following .NET CLI command from the project root directory. + +{% tabs %} +{% highlight bash tabtitle=".NET CLI" %} + +dotnet run + +{% endhighlight %} +{% endtabs %} + +## See also + +* [Getting started with Blazor DataGrid](https://blazor.syncfusion.com/documentation/datagrid/getting-started-with-server-app) +* [Getting started with Blazor Scheduler](https://blazor.syncfusion.com/documentation/scheduler/getting-started-with-server-app) +* [Getting started with Blazor Rich Text Editor](https://blazor.syncfusion.com/documentation/rich-text-editor/getting-started-with-server-app) diff --git a/blazor/common/migration/wpf-blazor-migration.md b/blazor/common/migration/wpf-blazor-migration.md new file mode 100644 index 0000000000..10afea223c --- /dev/null +++ b/blazor/common/migration/wpf-blazor-migration.md @@ -0,0 +1,658 @@ +--- +layout: post +title: Migrating WPF Controls to Blazor Components | Syncfusion +description: Step-by-step guide to migrate WPF controls to Blazor components on .NET 8+, including setup, configuration, code examples, and migration limitations. +platform: Blazor +component: Common +documentation: ug +--- + +# Migrating WPF Controls to Blazor Components + +Migrating enterprise applications from **[WPF (Windows Presentation Foundation)](https://learn.microsoft.com/en-us/dotnet/desktop/wpf/overview/)** to **[Blazor](https://learn.microsoft.com/en-us/aspnet/core/blazor/)** involves a significant architectural transition, moving from a rich, XAML-based desktop client framework to a component-driven, cross-platform web framework running on .NET. This guide provides a structured, step-by-step migration approach for **[WPF Controls](https://www.syncfusion.com/wpf-controls)** to their corresponding **[Blazor components](https://www.syncfusion.com/blazor-components)** with the **Blazor Web App (Interactive Server)** rendering mode. + +## Why migrate from WPF to Blazor? + +| Dimension | WPF | Blazor Web App (Interactive Server) | +|---|---|---| +| Runtime | Windows desktop app on .NET Framework or modern .NET | Web app on .NET with interactive server rendering | +| UI definition | XAML-based UI with code-behind | Razor components with HTML and C# | +| Code-behind / logic | `.xaml.cs` files or view models | `@code { }` blocks or `.razor.cs` partial classes | +| Pattern | MVVM is commonly used | Component-based development is the standard approach | +| Data binding | Uses `DataContext` and view models | Uses component parameters, `@bind`, and cascading values | +| State management | Uses view model state and `INotifyPropertyChanged` | Uses component state and re-rendering | +| Navigation | Uses windows, `Frame`, or region-based navigation | Uses `@page` routing and `NavigationManager` | +| Dependency injection | Often uses external containers | Uses built-in .NET dependency injection | +| Rendering | Uses the native WPF rendering pipeline | Uses interactive rendering in the browser | +| Communication model | In-process desktop interaction | Server interaction over SignalR for interactivity | + +## Prerequisites for Blazor + +* [.NET 8 SDK or later](https://dotnet.microsoft.com/en-us/download/dotnet) +* [Visual Studio](https://visualstudio.microsoft.com/downloads/) 2022 or later or [Visual Studio Code](https://code.visualstudio.com/) with [C# Dev Kit](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csdevkit) extension + +## Project structure comparison + +WPF and Blazor follow different application models. The following table maps common WPF artifacts to their closest Blazor equivalents and describes their roles in a Blazor application. + +| WPF artifact | Blazor equivalent | Description | +|---|---|---| +| `App.xaml` | `Program.cs` and `App.razor` | Defines startup and root rendering | +| `App.xaml.cs` | `Program.cs` | Configures services and host setup | +| `MainWindow.xaml` | `App.razor`, `MainLayout.razor`, and `Routes.razor` | Represents the application shell and routing structure | +| `Views/*.xaml` | `Pages/*.razor` | Defines route-enabled UI pages | +| `ViewModels/*.cs` | Services, component state, or `.razor.cs` | Contains UI logic and state | +| `Models/*.cs` | `Models/*.cs` | Usually reusable without changes | +| `Services/*.cs` | `Services/*.cs` | Handles shared application logic through dependency injection | +| `ResourceDictionary` | CSS, CSS isolation, and static assets | Manages styling and static resources | +| `UserControl` | Razor component (`.razor`) | Reusable UI component | +| `ICommand` and `RelayCommand` | Event handlers, `EventCallback`, component methods, or custom services | Implements user action handling and validation logic in Blazor using event callbacks or service methods | +| `INotifyPropertyChanged` | Component state and re-rendering | Updates the UI when state changes | + +## Common setup and configuration + +Create a Blazor project using one of the following getting started guides. + +* [Getting Started with Blazor Web App](https://blazor.syncfusion.com/documentation/getting-started/blazor-web-app) +* [Getting Started with Blazor Server App](https://blazor.syncfusion.com/documentation/getting-started/blazor-server-side-visual-studio) +* [Getting Started with Blazor WebAssembly App](https://blazor.syncfusion.com/documentation/getting-started/blazor-webassembly-app) + +This migration guide focuses on the **Blazor Web App (Interactive Server)** approach, which provides the most direct migration path from WPF by maintaining server-side logic and state management similar to traditional desktop applications. The interactive server rendering mode enables real-time server-client communication through SignalR, making it suitable for enterprise applications that require complex business logic and real-time updates. + +The following shared setup applies to all components and covers the common configuration required before proceeding to the [component-specific migration steps](#component-specific-migration-steps). + +### Package installation + +In WPF applications, controls are typically installed as individual NuGet packages (for example, [Syncfusion.SfGrid.WPF](https://www.nuget.org/packages/Syncfusion.SfGrid.WPF) and [Syncfusion.SfChart.WPF](https://www.nuget.org/packages/Syncfusion.SfChart.WPF)) and referenced directly in XAML and code-behind. + +In Blazor applications, components are also provided as individual NuGet packages (for example, [Syncfusion.Blazor.Grid](https://www.nuget.org/packages/Syncfusion.Blazor.Grid) and [Syncfusion.Blazor.Charts](https://www.nuget.org/packages/Syncfusion.Blazor.Charts)). Installing only the required component packages improves performance and reduces application size. + +For the complete list of available packages, refer to the [Blazor NuGet packages](https://blazor.syncfusion.com/documentation/nuget-packages). + +Additionally, install the [Syncfusion.Blazor.Themes](https://www.nuget.org/packages/Syncfusion.Blazor.Themes) NuGet package at the application level to enable styling. + +### Service registration + +In WPF, controls are usually declared in XAML and initialized in code-behind, so you do not need to register them explicitly. Application services are typically configured manually or through an external DI container. + +Blazor uses the built-in .NET dependency injection (DI) system, so required services must be registered in the application's service container to enable component communication and framework functionality. When using **Blazor Web App (Interactive Server)**, ensure that services are registered with the appropriate lifetime scope to support interactive components and server-side state management. + +In the `Program.cs` file, add the following namespace and register the required services. + +{% tabs %} +{% highlight c# tabtitle="Program.cs" hl_lines="2 8" %} + +... +using Syncfusion.Blazor; +... +var builder = WebApplication.CreateBuilder(args); +builder.Services.AddRazorComponents() + .AddInteractiveServerComponents(); +// Register Blazor services +builder.Services.AddSyncfusionBlazor(); +... + +{% endhighlight %} +{% endtabs %} + +### Add required namespaces + +In Blazor applications, after installing the required packages and registering services, import the necessary namespaces in the `_Imports.razor` file. + +{% tabs %} +{% highlight razor tabtitle="_Imports.razor" %} + +@using Syncfusion.Blazor +@using Syncfusion.Blazor.Grids +@using Syncfusion.Blazor.Charts +@using Syncfusion.Blazor.Schedule + +{% endhighlight %} +{% endtabs %} + +This example includes the namespaces used by the components covered in this guide. Import only the namespaces needed for the components used in your application. + +### Theme and script configuration + +**WPF approach** + +In WPF, themes are typically applied using [SfSkinManager](https://help.syncfusion.com/wpf/themes/skin-manager), while additional styling can be managed through `ResourceDictionary` and XAML-based styling. Scripts are not required because rendering happens locally in the desktop runtime. + +{% tabs %} +{% highlight xml tabtitle="MainWindow.xaml" %} + + + ... + + +{% endhighlight %} +{% endtabs %} + +**Blazor equivalent** + +In Blazor, the theme stylesheet and script can be accessed from NuGet through [Static Web Assets](https://blazor.syncfusion.com/documentation/appearance/themes#static-web-assets). Include the [stylesheet](https://blazor.syncfusion.com/documentation/appearance/themes) and [script references](https://blazor.syncfusion.com/documentation/common/adding-script-references) in the **App.razor** file. + +{% tabs %} +{% highlight html tabtitle="App.razor" %} + + + ... + + + ... + + + + ... + + + + +{% endhighlight %} +{% endtabs %} + +## Understanding Data Binding Between DataContext and Blazor Parameters + +Data binding is a fundamental concept in both WPF and Blazor, but the implementation approaches differ significantly. + +### WPF DataContext approach + +In WPF, the `DataContext` property is a powerful mechanism that enables declarative data binding. You set the `DataContext` to a view model instance that typically implements `INotifyPropertyChanged`, and XAML bindings automatically resolve against this object. This allows UI elements to automatically update when the underlying data changes. + +When the data source implements [INotifyCollectionChanged](https://learn.microsoft.com/en-us/dotnet/api/system.collections.specialized.inotifycollectionchanged?view=net-10.0) (such as [ObservableCollection](https://learn.microsoft.com/en-us/dotnet/api/system.collections.objectmodel.observablecollection-1?view=net-10.0)), the [SfDataGrid](https://www.syncfusion.com/wpf-controls/datagrid) control automatically refreshes the UI when items are added, removed, or when the list is cleared. However, when using a standard `List`, the grid will not automatically refresh when the collection is modified. + +{% tabs %} +{% highlight c# tabtitle="MainWindow.xaml.cs" %} + +using System.ComponentModel; +using System.Collections.ObjectModel; + +public partial class MainWindow : Window +{ + public MainWindow() + { + InitializeComponent(); + // Set the DataContext to bind XAML elements to the view model + this.DataContext = new OrderViewModel(); + } +} + +public class OrderViewModel : INotifyPropertyChanged +{ + private ObservableCollection orders; + + public ObservableCollection Orders + { + get { return orders; } + set + { + if (orders != value) + { + orders = value; + OnPropertyChanged(nameof(Orders)); + } + } + } + + public OrderViewModel() + { + Orders = new ObservableCollection + { + new Order { OrderID = 10248, CustomerID = "VINET", Freight = 32.38 }, + new Order { OrderID = 10249, CustomerID = "TOMSP", Freight = 11.61 }, + new Order { OrderID = 10250, CustomerID = "HANAR", Freight = 65.83 } + }; + } + + public event PropertyChangedEventHandler PropertyChanged; + + private void OnPropertyChanged(string propertyName) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } +} + +public class Order +{ + public int OrderID { get; set; } + public string CustomerID { get; set; } + public double Freight { get; set; } +} + +{% endhighlight %} +{% endtabs %} + +### Blazor parameter and binding approach + +In Blazor, data flows through component parameters and the `@bind` directive. Instead of a global `DataContext`, each component explicitly defines its data dependencies through parameters. This approach provides more explicit data flow, better component composition, and type-safe binding. + +The [Blazor DataGrid](https://www.syncfusion.com/blazor-components/blazor-datagrid) supports binding to any `IEnumerable` collection such as `List`, [ObservableCollection](https://learn.microsoft.com/en-us/dotnet/api/system.collections.objectmodel.observablecollection-1?view=net-10.0), collections of [ExpandoObject](https://learn.microsoft.com/en-us/dotnet/api/system.dynamic.expandoobject?view=net-10.0), [DynamicObject](https://learn.microsoft.com/en-us/dotnet/api/system.dynamic.dynamicobject?view=net-10.0), or `DataTable`, directly to the [DataSource](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_DataSource) property of the Grid. When using `ObservableCollection`, the component automatically reflects changes made externally. For standard `List`, call the [Refresh](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_Refresh_System_Boolean_) method to reflect externally made changes to avoid tracking changes for performance considerations. + +{% tabs %} +{% highlight razor tabtitle="Orders.razor" %} + +@page "/orders" +@rendermode InteractiveServer +@using Syncfusion.Blazor.Grids + + + + + + + + + +@code { + private List Orders = new(); + + protected override void OnInitialized() + { + // Component state is initialized with data + Orders = new List + { + new Order { OrderID = 10248, CustomerID = "VINET", Freight = 32.38 }, + new Order { OrderID = 10249, CustomerID = "TOMSP", Freight = 11.61 }, + new Order { OrderID = 10250, CustomerID = "HANAR", Freight = 65.83 } + }; + } + + public class Order + { + public int OrderID { get; set; } + public string CustomerID { get; set; } + public double Freight { get; set; } + } +} + +{% endhighlight %} +{% endtabs %} + +**Key differences in data binding** + +| Aspect | WPF DataContext | Blazor Parameters | +|---|---|---| +| Scope | Global to window/control hierarchy | Explicit per component | +| Binding declaration | `{Binding PropertyName}` in XAML | `@PropertyName` or `@bind` in Razor | +| Property changes | `INotifyPropertyChanged` triggers UI updates | Component state changes trigger re-renders | +| Collection type | `ObservableCollection` for automatic notifications | `List` or `ObservableCollection` (for `ObservableCollection`, automatic notifications; for `List`, call [Refresh()](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_Refresh_System_Boolean_) method) | +| Type safety | Resolved at runtime | Type-safe at compile time | +| Two-way binding | `{Binding PropertyName, Mode=TwoWay}` | `@bind-Value="@PropertyName"` | +| Update notification | Automatic via `PropertyChanged` event | Automatic for `ObservableCollection` or manual via `Refresh()` or re-assignment for `List` | +| Data sources supported | Collections implementing `INotifyCollectionChanged` or `IEnumerable` | `IEnumerable` collections: `List`, `ObservableCollection`, `ExpandoObject`, `DynamicObject`, `DataTable` | + +## Component-specific migration steps + +### DataGrid + +[WPF DataGrid](https://www.syncfusion.com/wpf-controls/datagrid) is a high-performance XAML-based tabular control for desktop applications, while [Blazor DataGrid](https://www.syncfusion.com/blazor-components/blazor-datagrid) is the web-first Razor component for building responsive, interactive, data-driven web interfaces. + +For additional details, refer to the [WPF DataGrid getting started guide](https://help.syncfusion.com/wpf/datagrid/getting-started) and [Blazor DataGrid getting started guide](https://blazor.syncfusion.com/documentation/datagrid/getting-started-with-server-app). + +| Aspect | WPF (SfDataGrid) | Blazor (SfGrid) | +|---|---|---| +| Package (NuGet) | [Syncfusion.SfGrid.WPF](https://www.nuget.org/packages/Syncfusion.SfGrid.WPF) | [Syncfusion.Blazor.Grid](https://www.nuget.org/packages/Syncfusion.Blazor.Grid) | +| Component declaration | `` | `` | +| Data binding | [ItemsSource](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.Grid.SfDataGrid.html#Syncfusion_UI_Xaml_Grid_SfDataGrid_ItemsSource) with `DataContext` or a view model | [DataSource](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_DataSource) with component state | +| Collection type | `ObservableCollection` (automatic notifications) | `List` or `IEnumerable` (state updates trigger re-renders) | +| Columns | [GridTextColumn](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.Grid.GridTextColumn.html), [GridNumericColumn](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.Grid.GridNumericColumn.html), [GridTemplateColumn](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.Grid.GridTemplateColumn.html) | [GridColumn](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.GridColumn.html) with [Field](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.GridColumn.html#Syncfusion_Blazor_Grids_GridColumn_Field), [Format](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.GridColumn.html#Syncfusion_Blazor_Grids_GridColumn_Format), and [EditType](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.GridColumn.html#Syncfusion_Blazor_Grids_GridColumn_EditType) | +| Templates | XAML `DataTemplate` | Razor `