Quantcast
Channel: Telerik Blogs | .NET
Viewing all 1954 articles
Browse latest View live

Throwing .NET Exceptions: ArgumentNullException and ArgumentOutOfRangeException

$
0
0

Application code must differentiate between exceptions caused by null/non-null arguments. This post shows you how to raise such exceptions.

Exceptions can be thrown either by the runtime or the application code. This can be caused by bad code, or by bad user input that has not been accounted for in the application's code. When any of these errors occur, the system catches the error and raises an exception.

The process of generating and signaling the error is referred to as throwing an exception. This is done using the throw keyword followed by a new instance of a class derived from System.Exception. There are standard exception types provided by the .NET framework that you can use rather than creating a custom exception.

In this post, I'll show you how to use the ArgumentNullException and ArgumentOutOfRangeException types, which are some of the standard exceptions in the framework.

Throwing ArgumentOutOfRangeException

The ArgumentOutOfRangeException exception can be thrown when the argument passed to a method is not null and contains a value that is not within the set of expected values. This exception type has the properties ParamName and ActualValue, which help us understand the cause of the exception. The ParamName property identifies the parameter name of the invalid argument, and the ActualValue property identifies the invalid value if a value is present.

The ArgumentOutOfRangeException exception would normally result from developer error, and if the value of the argument is returned by a method call or input from the user before being passed to the method that throws the exception, you should validate arguments before passing them to the method.

Let's look at an example.

namespace MyApp
{
  using System;

  class Program
  {
    static void Main(string[] args)
    {
      try
      {
        Console.WriteLine("Enter account name");
        var name = Console.ReadLine();

        Console.WriteLine("Enter opening balance");
        var balance = Convert.ToInt32(Console.ReadLine());

        Console.WriteLine("Opening account for {0}... \n", name);
        var account = new Account(name, balance);

        Console.WriteLine("Account opened for {0}", account.Name);
      }
      catch (ArgumentOutOfRangeException ex)
      {
        Console.WriteLine(ex);
      }
    }
  }

  class Account
  {
    public Account(string name, int balance)
    {
      if (balance < 500)
        throw new ArgumentOutOfRangeException(
          nameof(balance),
          balance,
          "The account balance can't be less than 500");

      Name = name;
      Balance = balance;
    }

    public string Name { get; private set; }
    public int Balance { get; private set; }
  }
}

In the code above, we have an Account class with properties Name and Balance, and a constructor that accepts name and balance as parameters. When this constructor gets a balance less than 500, it'll throw an ArgumentOutOfRangeException exception with the parameter name that caused the exception, the value of the argument, and message explaining the cause of the error. In the static Main method, we collect the name and balance from the user, then create an Account object with that information.

If we run the application and enter a value less than 500 for the balance, we will get an exception. The information below is what we get when we run the code with 300 as the balance.

Enter account name
Jumbo
Enter opening balance
300
Opening account for Jumbo...
System.ArgumentOutOfRangeException: The account balance can't be less than 500
Parameter name: balance
Actual value was 300.

Throwing ArgumentNullException

It is useful to differentiate between exceptions caused by null arguments and exceptions caused by arguments that are not null. The ArgumentNullException exception type derives from the ArgumentException class and is used to identify exceptions caused by null arguments. This exception is thrown when a null value is passed to a method argument and null is not allowed for that argument.

The code below is an example of how to use this exception type.

using System;

namespace MyApp
{
  class Program
  {
    static void Main(string[] args)
    {
      try
      {
        var user = new User(null, 23);
      }
      catch (ArgumentNullException ex)
      {
        Console.WriteLine(ex);
      }
    }
  }

  class User
  {
    public User(string userName, int age)
    {
      if (userName == null)
        throw new ArgumentNullException(
          nameof(userName),
          "username is invalid");

      UserName = userName;
      Age = age;
    }

    public string UserName { get; private set; }
    public int Age { get; private set; }
  }
}

Here we declared a User class with properties UserName and Age. In the class constructor, we accept two parameters and assign them to the appropriate properties. Before the assignment, we check if userName is null. If it is, we throw an ArgumentNullException. We called the constructor of ArgumentNullException that accepts the parameter name that caused the exception and a second parameter representing the exception message. You might have noticed we used the nameof operator to get the string name of the parameter that caused the exception. Using the nameof operator helps keep your code valid when renaming definitions.

If you run the code, it should throw an exception because userName is null and also specify the parameter name to easily identify which parameter caused the exception.

Conclusion

An exception is thrown when an error is encountered in a running application. This could be a result of bad code or bad user input that has not been accounted for in the application's code.

In this post we looked at two standard exception types from the .NET framework, the ArgumentNullException and ArgumentOutOfRangeException types. The ArgumentOutOfRangeException exception is thrown when the value of an argument is outside the expected range of values as defined by the invoked method. The ArgumentOutOfRangeException exception normally results from developer error, so when dealing with this kind of error, be sure to read the value of the properties Message, ParamName, and ActualValue. The ArgumentNullException is thrown when a null value is passed to a method that does not accept null values as valid input. They're provided so that application code can differentiate between exceptions caused by null arguments and exceptions caused by arguments that are not null.


Introducing Telerik UI for Blazor 1.0.0

$
0
0

I am happy to be able to announce Telerik UI for Blazor is officially out of the preview and experimental stage and now enters a new era: official RTM! Telerik UI for Blazor 1.0.0 is here!

It’s crazy to think about how Telerik UI for Blazor was in its initial preview just a few months ago. Now, after several releases, lots of feedback from Blazor fans, and huge steps for the Blazor framework itself, we are finally here to chat about this new official product in the Telerik family of UI component suites.

Wait, What is this Blazor Thing?

Blazor is an exciting new framework coming from Microsoft that takes advantage of WebAssembly in order to allow developers to use C# to target web applications instead of using JavaScript.

That’s right, you heard me, you can now develop rich web applications using C# where you normally would use JavaScript! Obviously this is huge for many .NET developers out there.

This blog post isn’t necessarily meant to give everyone a full 101 intro to Blazor, but keep the above in mind as you go through the rest of this blog post. If you’re interested in knowing more about Blazor itself head over to the official Blazor page that I linked in the beginning of this section.

How Telerik Approaches Blazor UI Components

One thing I’d like to note about Telerik UI for Blazor is that we have decided to build these components from the ground up, making them completely native to the Blazor framework.

During our initial research into how we should approach a set of UI components for Blazor, we had two paths we could take: wrap existing JavaScript components (Kendo UI specifically) or build up a new set of components from scratch. While wrapping would give us a quick win, essentially offering over 70 UI components from the get-go, we realized that we could quickly run into issues integrating with the Blazor framework itself, like working with validation, templates, and other items.

Our philosophy while building these components is to keep the JavaScript interops to a minimum. The strength of Blazor is to use C# rather than JavaScript after all. There will still be some interops needed here and there, but as I mentioned these will be kept to a minimum going forward.

So, What’s in 1.0.0?

With the initial release of Telerik UI for Blazor we have the following UI components ready for you right out of the box.

  • Button
  • Calendar
  • Chart
  • Date Input
  • Date Picker
  • DropDownList
  • Grid
  • Numeric Textbox
  • TabStrip
  • TextBox
  • Window
  • Animation Container

That’s a huge amount of components! With this list you can clearly already start developing pretty advanced applications using Blazor.

All of the input components can take advantage of Blazor’s validation framework and there’s full support for templates across the board.

One of the heavier hitters here is obviously the native Grid component. Just as a quick highlight, here are the initial features we have managed to squeeze in to the Grid (with more to come of course).

  • Paging
  • Sorting
  • Filtering
  • Show/Hide Columns
  • Cell Templates
  • In-cell Editing
  • Inline editing
  • Popup Editing
  • Custom form for editing
  • Custom editor (editor templates)

There’s just so much to showcase in the components that I can’t put it all in a blog post, so instead I recommend heading over to the demo site for Telerik UI for Blazor. Quick note: this is actually a full Blazor app!

If you’ve already been using Telerik UI for Blazor in its earlier iterations I recommend heading over to our What’s New in Telerik UI for Blazor 1.0.0 page.

ThemeBuilder Support

Just like we have with all of our other web-based components, we have added Telerik UI for Blazor into the ThemeBuilder tool. This makes customizing any of the available themes extremely easy through just a couple of clicks. Any changes you make to the look-and-feel will automatically be updated in the list of components rendered on the page, which gives you immediate feedback around what your changes are doing to the components.

Blazor Sample Application

With this first release we have also created a sample application showcasing the power of the Blazor framework - with Telerik UI for Blazor in charge of the UI components for said application. Since we have Grids, Charts, and Form elements as a part of 1.0.0, it makes a ton of sense to showcase these in a dashboard application. So, if you’re interested in seeing a Blazor app in action head on over to the Telerik UI for Blazor Dashboard Sample application.

Where Can I Find Out More?

To find out more or share your thoughts about Telerik UI for Blazor, I can recommend a few places to go:

All of these pages are great to keep bookmarked and handy for learning more about Telerik UI for Blazor. Of course, the demos and docs will be something that you should definitely bookmark since that’s where you can learn the most about the components, how to use them, and their API.

Sign Up for A Trial

I’m incredibly excited that Telerik UI for Blazor 1.0.0 is here, and I’m sure you are too! If you’re interested in tinkering around with Blazor, or if you’re already actively working with Blazor to develop applications I encourage you to check out Telerik UI for Blazor.

In order to get ahold of the bits you will need to sign up for a trial, which gives you access to the components as well as our support ticketing system. Head on over to the Telerik UI for Blazor overview page or click the button below and sign up for a trial today!

Try Telerik UI for Blazor

Of course, this is just the beginning of the Telerik UI for Blazor journey, so stay tuned for more updates, new components, and tons of new features coming out later this year!

The Missing Ingredient to Your Spreadsheets—Charts

$
0
0

Telerik UI for WPF recently introduced a major feature for the RadSpreadsheet and RadSpreadProcessing components - adding charts to your spreadsheet documents to visualize data and more. Learn how you can use it in your spreadsheets today.

I bet most of you love charts. Those sets of elements that combined together can make a lovely graphical representation of your data. Bar charts, line charts, pie charts, area charts - so many charts! - and if used properly, they make your data come to life. I am happy to announce that this essential ingredient is now part of the RadSpreadsheet control and RadSpreadProcessing library in Telerik UI for WPF.

With only few steps you can now transform your data into a beautiful chart.

How to Add Charts in Your Spreadsheet

It is pretty easy actually. Once you have your spreadsheet ready and all the data typed in the cells, go to the “Insert” menu tab item and click the “All Charts” button. You can then choose among the chart types you would like to use. This approach should be automatically available for you if you are using Telerik UI for WPF R1 2019 version or higher.

Telerik UI for WPF - Spreadsheet - Charts

Another way to create charts is to work directly with the Charts API.

Supported Chart Types

Let me briefly introduce what kind of charts can be used at this time with RadSpeadsheet and RadSpreadProcessing, and what they are best for.

  • Line: Best for showing values change over time. They work very well for a high number of values increasing or decreasing continuously.
  • Column: Display values as sets of columns grouped by category. Great choice for showing columns that grow from smallest on the left to largest on the right on the horizontal axis. Used to compare values of each category. Good for showing ordinal data.
  • Bar: Analogical to the Column chart type. The main difference is the orientation of the bars. Good in situations when you have long category labels. Good for showing nominal data (ranges).
  • Pie and Doughnut: Easily understood they display percentage of proportional data where each slice represents percentage of the whole. Doughnut charts extend the Pie charts further by being able to show more than one set of data.
  • Area: Used in scenarios to plot change over time and draw attention to the total value across a trend. As opposed to Line charts, Area charts are able to show volume.
  • Scatter [coming in R2 2019]: Used when you want to show the relationship between two variables. Good for comparing large number of data points. Both axes of Scatter chart are Value axes.
  • Bubble [coming in R2 2019]: A bubble chart is a variation of a scatter chart in which the data points are replaced with bubbles. In addition to the Scatter chart, Bubble plots X values, Y values and Z values (size).

charts

Create an Empty Chart and Set its Values Manually

You can create a simple DocumentChart object, which is empty, and can then set the desired values. This object represents the chart itself and contains the following properties:

  • SeriesGroup: Represents a collection of the groups in which the series of the chart are organized.
  • PrimaryAxes: Represents the primary group of axes of the chart.
  • SecondaryAxes: Represents the secondary group of axes of the chart. It is used when there is more than one group of series (combo chart).
  • Title: Represents the title of the chart.
  • Legend: Represents the legend of the chart.

Create a Chart through FloatingChartShape and Add it to a Worksheet

And how do you bind the data and the chart? Let’s assume you have your data already populated in a document within the following range of cells:

Now let’s execute the code below:

FloatingChartShape chartShape = newFloatingChartShape(this.radSpreadsheet.ActiveWorksheet, newCellIndex(2, 7), newCellRange(0, 0, 4, 3), ChartType.Column)
{
Width = 480,
Height = 288,
};
chartShape.Chart.Legend = newLegend() { Position = LegendPosition.Right };
chartShape.Chart.Title = newTextTitle( “Sold Top Products (Monthly)");
this.radSpreadsheet.ActiveWorksheet.Shapes.Add(chartShape);

In a blink of an eye we now have the following column chart:

charts_sold_top_products

The charts are wrapped in shapes. FloatingChartShape class is the wrapper allowing you to add a chart to a document. It exposes the following constructors, which parse the data in the chartDataRange parameter and create a chart with all data already filled:

FloatingChartShape(Worksheet worksheet, CellIndex cellIndex, CellRange
chartDataRange,
paramsChartType[] chartTypes)
FloatingChartShape(Worksheet worksheet, CellIndex cellIndex, CellRange chartDataRange, SeriesRangesOrientation seriesRangesOrientation, paramsChartType[] chartTypes)

Legend and Title

You probably noticed that running the code above adds a legend to the chart. Adding the legend is a piece of cake. It can be added or edited through the Legend property of the DocumentChart object and can be positioned through the LegendPosition enumeration with members for Top, Bottom, Left and Right.

The same is also true for chart’s title.You can access and set it by using the Title property of the DocumentChart.

Insert Chart Dialog

Wait! What if you don’t have a document containing your data, and you would like to create everything from scratch? Using the RadSpreadsheet control, just fill in your data and simply select the cells. Then insert a chart via the "All Charts" button located under the "Insert" menu item.

CreateChartViaInsertChartDialog

Hitting the "All Charts" button brings us to the "Insert Charts" dialog. And a question comes to my mind. What if you are not sure what type of chart would best fit your scenario, or you simply want to see how your data would look like in a Bar chart instead of a Column chart (just in case if you are not sure that your labels are short enough)?

Working with RadSpreadsheet’s UI gives you the ability to choose between all available chart types supported by RadSpreadsheet through the “Insert Charts” dialog. We are working on providing more and more chart types which will automatically be added to the dialog, so stay tuned for more.

Update Chart Data

So far, so good. It looks great, doesn’t it? But what if you want to make changes to the data? That ability is only a few keystrokes away. Select and update the cell values and all the changes will be automatically applied to the bound chart. Do this by editing the document via RadSpreadsheet’s UI or using the Charts API.

update_chart

Exporting Charts

And that’s not all. An essential part of RadSpreadsheet’s model is the ability to export a document to another file format. Charts can easily be exported to PDF and Excel though XlsxFormatProvider and PdfFormatProvider.

What’s Next

We are planning on supporting more of the most commonly used chart types and we will keep you posted. Please share your thoughts and feedback about what other chart types would you expect or what could be improved. Help us make Telerik UI for WPF even better!

For those of you who are hearing about Telerik UI for WPF for the first time and want to learn more, head over to the product page or download a free trial today to get started.

Comparing Native Blazor Components to Wrapped JavaScript Components

$
0
0

Should we rewrite native UI components or reuse existing JavaScript UI components? We compare native Blazor components to wrapped JavaScript components by understanding how Blazor works, including what native vs. interop means and more.

Blazor is a new Single Page Application (SPA) framework that utilizes WebAssembly to run .NET application code in the browser. This future-forward framework allows developers to leverage their existing .NET code and skills to create web applications that can run completely client-side without the need for browser plug-ins. As with any new web framework, we're presented with a challenging decision of bringing along assets from previous works into the new system.

In the case of Blazor, the challenge presents itself in the User Interface (UI) components of the application model. Due to previous lack of choice, web UIs are written in JavaScript, whereas Blazor heavily utilizes the C# language and Razor markup syntax. This stark contrast of choices forces one's hand in one of two directions - rewrite native UI components or reuse your JavaScript UI components.

Let's explore the challenge by understanding how Blazor works, what native vs. interop means, all while discussing the tradeoffs of choosing between the two approaches.

Blazor Architecture Basics

Blazor is a new breed of web application framework, a first of its kind. Blazor is similar in many respects to React or Angular, but what sets it apart is the underlying architecture is crafted upon WebAssembly instead of JavaScript.

WebAssembly (WASM) is a web standard, developed by the World Wide Web Consortium (W3C), that defines an assembly-like binary code format for execution in web pages. WebAssembly is the cornerstone of Blazor in that it provides a platform for the Mono Runtime for WebAssembly, a .NET runtime compiled to WASM format.

A Blazor application is a true .NET application, running on a .NET runtime inside the browser. This is quite an important factor in the decision process when it comes to writing UI components for Blazor, as you should know the context in which the component is executed.

Blazor Architecture: DOM Abstraction

Much like its JavaScript siblings, Angular and React, Blazor employs a similar approach to handling changes to the Document Object Model (DOM). No matter what framework you choose, DOM manipulation is a taxing process which is often compounded by directly changing its structure more frequently than necessary. Without a proper execution plan, most approaches to DOM manipulation destroy and rebuild chunks of DOM, ripping out multiple nodes and repainting them. This is a solved problem in modern frameworks through the use of a DOM abstraction.

The DOM abstraction in Blazor is called the RenderTree, it's a lightweight representation of the DOM. Think of the RenderTree as copy where changes can be quickly made as nodes in this tree can be created, updated and deleted without consequence of re-rendering the page. Now multiple components in the system can make changes against the RenderTree at once with much less of a performance hit. When the dust has settled, the RenderTree and DOM are reconciled by looking for the differences between the two and re-rendering only what's absolutely necessary.

The RenderTree is vital to UI components behavior and render speed. It's also an important aspect to choosing between how to write UI components, especially when it comes to JavaScript.

Blazor Architecture: Native Components

In a Blazor application, components (.razor) are actually processed quite differently from traditional Razor (.cshtml) markup. Razor in the context of MVC or Razor Pages is processed directly to HTML, which is rendered server side and sent over an HTTP request. A component in Blazor takes a different approach - its markup is used to generate a .NET class that builds the RenderTree.

<h1>Counter</h1>

<p>Current count: @currentCount</p>

<button class="btn btn-primary" onclick="@IncrementCount">Click me</button>

Each HTML element in the component gets passed to the RenderTreeBuilder and given a sequence number used to quickly differentiate changes in the DOM.

    public class Counter : ComponentBase
    {
        protected override void BuildRenderTree(RenderTreeBuilder builder)
        {
            base.BuildRenderTree(builder);
            builder.AddMarkupContent(0, "<h1>Counter</h1>\r\n\r\n");
            builder.OpenElement(1, "p");
            builder.AddContent(2, "Current count: ");
            builder.AddContent(3, currentCount);
            builder.CloseElement();
            builder.AddContent(4, "\r\n\r\n");
            builder.OpenElement(5, "button");
            builder.AddAttribute(6, "class", "btn btn-primary");
            builder.AddAttribute(7, "onclick", M...<UIMouseEventArgs>(this, IncrementCount));
            builder.AddContent(8, "Click me");
            builder.CloseElement();
        }

This component architecture is fundamental to Blazor's operation and supports features built into the framework such as: component life cycle methods, templates and validation.

Blazor Architecture: JavaScript Wrappers

A "native" Blazor component is one that is written using the framework's component architecture, a component that has a RenderTree and hooks into life cycle methods. The alternative is to create a wrapper for preexisting JavaScript components. When using JavaScript a component is created that exposes a set of properties and methods that map to a JavaScript implementation. On the surface a JavaScript based component is used like native component, but under the surface it bypasses the RenderTree and the HTML is rendered by directly manipulating the DOM.

The Blazor RenderTree process vs. direct DOM manipulation. RenderTree consolidates updates, takes the delta, performs a single update. JavaScript updates even when it is not necessary.

The ability to perform calls to JavaScript from within a Blazor application is called the JavaScript interop. The interop is a necessary feature of Blazor as it bridges any gaps between WebAssembly and DOM APIs. This is especially useful for things not supported in Blazor like: GeoLocation, File Access, and Camera APIs to name a few. It's a very powerful tool, but it can easily become bad practice as it can circumvent the Blazor virtual DOM.

Leaky Abstractions

In software development, a leaky abstraction is an abstraction that leaks details that it is supposed to abstract away. Wrappers have a natural tendency to fall victim to this definition. Because wrappers need support from outside the Blazor framework, they require additional details like id and ref attributes. Legacy JavaScript code relies heavily on ids and elementRefs. Since they exist outside of the RenderTree, they need to be located in the DOM by traversing the DOM structure and then manipulated, a costly routine. If these are required attributes for a UI component library you can assume its heavily dependent on JavaScript.

<AcmeWidget ID="myThing" ref="myReference" ...>

Content & Template Support

Components are the building blocks of Blazor application and one of its strongest assets. Components can host other components in two ways - through Child Components and Templates - and as a result Blazor development is very nimble. Child Components and Templates are component properties with a special class called a RenderFragment, a delegate that writes the content to a RenderTreeBuilder. This is another oversight for components built from JavaScript wrappers and a prime reason to build native components.

Child components are extremely powerful as they can transform component behavior or composition of components. Such a feature can truly be appreciated by example. In the following code a TelerikTabStrip is given a list of Forecast objects, the list is iterated over using a simple foreach, building the tabs dynamically.

<TelerikTabStrip>
    @foreach (var f in Forecasts)
    {
        <TelerikTab Title=@f.City>
            <Weather City=@f.City
                     TempC=@f.Temp
                     Forecast=@f.Outlook>
            </Weather>
        </TelerikTab>
    }
</TelerikTabStrip>

The ability to declare components in this manner is due to the Blazor framework's component architecture and use of RenderFragments.

Dynamic components aren't limited to simple foreach loops either. Virtually any C# methodology can be applied to control rendering. In the next example, the same TelerikTabStrip component is used with an if statement which is bound to a check-box embedded within one of the child tabs. Changing the value of the check-box in this instance instantly effects the visibility of the first tab.

<TelerikTabStrip>
    @if (showFirstTab)
    {
        <TelerikTab Title="First Tab">
            This is the first tab.
        </TelerikTab>
    }
    <TelerikTab Title="Second Tab">
        <label>
            <input type="checkbox" bind=@showFirstTab />
            Toggle first tab
        </label>
    </TelerikTab>
</TelerikTabStrip>

This is possible because the scope of showFirstTab is outside of the component itself. Since the components are native they obey Blazor's rendering and data binding capabilities.

More advanced scenarios play out when Templates are used to allow for customization of how a component renders markup. Templates can be used for simple tasks like formatting values or displaying images, while more extensive Templates can transform the user interface completely, adding entirely new functionality to a component. For further reading on this subject, the article "Why Blazor Grid Templates Will Make You Question Everything" gives a comprehensive overview with code examples.

Pre-Rendering

Blazor isn't just capable of running client side, it can be hosted server-side as well. When Blazor runs server-side it has the ability to pre-render views to eliminate loading screens and enhance SEO. The way pre-rendering works in Blazor is similar to how ASP.NET Razor views and pages are rendered. In fact, because of this Blazor components are compatible with ASP.NET Razor views and pages. When using JavaScript based components, the server can not pre-render the component as JavaScript is not yet available. Instead, the page will need to be rendered by JavaScript when it is parsed by the client. It's important to be aware that this mode of operation is unavailable when wrapping existing JavaScript components.

Validation

Validation in Blazor is tightly coupled with the core component system. Since Blazor uses C# throughout the programming model, it supports the popular DataAnnotation method of defining validation.

using System.ComponentModel.DataAnnotations;

public class ExampleModel
{
    [Required]
    [StringLength(10, ErrorMessage = "Name is too long.")]
    public string Name { get; set; }
}

The DataAnnotations can be used to trigger validation within business logic on the server and also UI validation. The built-in EditForm component provides validation and event handlers that provide a seamless work-flow in the component model.

<EditForm Model="@exampleModel" OnValidSubmit="@HandleValidSubmit">
    <DataAnnotationsValidator />
    <ValidationSummary />

    <InputText id="name" bind-Value="@exampleModel.Name" />

    <button type="submit">Submit</button>
</EditForm>

@functions {
    private ExampleModel exampleModel = new ExampleModel();

    private void HandleValidSubmit()
    {
        Console.WriteLine("OnValidSubmit");
    }
}

Once again this is a scenario that plays out best when components are built using native components. Native components share a state called an EditContext that allows components within an EditForm to communicate. Native components that have integrated the EditContext automatically validate when placed within an EditForm without additional code. When trying to wrap existing JavaScript components validation requires leaky abstractions through the use of Id and ElementRef attributes.

Is JavaScript all Bad?

There is absolutely nothing wrong with using JavaScript libraries to support Blazor components. There are some use cases where JavaScript interop is a necessity to fill gaps as WebAssembly and Blazor are maturing products. One way that JavaScript interop can be beneficial is when it is used to augment native components by adding features that do not disturb the RenderTree, such as giving focus or providing keyboard navigation. In addition, JavaScript libraries can be used to add system level functionality when tapping into the DOM Web APIs like GeoLocation, File access, Canvas, and SVG.

Telerik is Native First

With Telerik UI for Blazor we have taken a native first development approach to building UI components. Our best practice is to take native implementation as far as the framework allows, leveraging the RenderTree, and allowing components to naturally hook into templates and validation. Our components make minimal use of JavaScript interop, ensuring that there are no leaky abstractions filtering up to the surface and getting in the customer's way. We have found extensive benefits with templates that offer an open-ended approach to web building applications.

Our Kendo UI brand of JavaScript components are a substantial asset to us and our customers, however we have determined that the best approach is to rebuild for Blazor with the knowledge we have gained from building UI components for Kendo UI. We can then apply it to Blazor using its fully native technologies, rather than wrapping the JavaScript work and passing it along to customers as something new.

Creating Single Page Applications in Blazor with the TelerikGrid and TelerikTabStrip

$
0
0

The TelerikGrid in Telerik UI for Blazor is a powerful tool for displaying multiple rows of objects. However, sometimes a grid can't provide a complete interface to the data. When that happens, for the most extensible solution, you can provide the user with the ability to switch from a row to the view they want. By integrating the TelerikGrid and the TelerikTabStrip, you can let the user select the item they want from a grid in one tab and then switch to another tab that shows additional information.

The source code for this article is available on GitHub: TelerikBlazorUIComponents

Configuring Events in the TelerikGrid

The first step in this process is to give the user the ability to select a row in the TelerikGrid. As of this writing, there isn't a native way to select an item in the grid (though there will be), but there are a couple of options you can use, including defining a template that includes a select button. For this post, however, I've chosen to exploit the event architecture of the TelerikGrid.

To access the TelerikGrid's events, first add the <TelerikGridEvents> element to the grid's markup, like this (for more about the TelerikGrid [Ed Note: formerly KendoGrid] see my earlier post):

<TelerikGrid Data="@customers">
  <TelerikGridEvents>
    <!-- ... -->
  </TelerikGridEvents>
  <!-- rest of grid markup... -->
</TelerikGrid>

As I said, while there is no OnSelect event in the grid's events, there are multiple other events (including OnDelete, OnUpdate, OnCreate, and OnCancel). For example, I can convert the existing OnEdit event into a “select row” UI event by tying it to a method in my page's functions block. I've called the method DisplayDetail:

<TelerikGridEvents>
  <EventsManager OnEdit="@((args) => DisplayDetail(args))"> />
</TelerikGridEvents>

By using a lambda expression, I've actually gone to more trouble here than I need to. I like the lambda-based syntax because it makes explicit that the grid will pass an argument to my DisplayDetail method. However, I could have achieved the same goal with just OnEdit="DisplayDetail".

To give the user a tool for selecting a row, I then add a TelerikGridCommandColumn as the first column in my <TelerikGridColumns> element. Within that element, I can add multiple buttons to the column using the <TelerikGridCommandButton> element – for this case, I only need one button. The Command attribute on the button lets me tie the button to one of the events specified in the <TelerikGridEvents> element (obviously, in this example, I'm going to use the “Edit” event). In addition, the TelerikGridCommandButton has an Icon attribute that lets me specify an icon to display in the button; I can also provide some text between the element's open and close tags to display as the button's caption. In this case, I stayed with the default edit icon and changed the caption text to “Select”:

<TelerikGridColumns>
  <TelerikGridCommandColumn>
    <TelerikGridCommandButton Command="Edit" Icon="edit">
      Select
    </TelerikGridCommandButton>
  </TelerikGridCommandColumn>
  <TelerikGridColumn Field="Id" Title="Customer Id" />
  <!-- more columns -->
</TelerikGridColumns>

Processing the Event

Now I need to write the method that will catch and process the event. I called my event DisplayDetail and I need to have it accept the GridCommandEventArgs object that the grid will pass to it. The skeleton for that method looks like this:

@functions
{  
  public void DisplayDetail(GridCommandEventArgs e)
  {
    // ...
  }

  // ...
}

The GridCommandEventArgs object has an Item property that points to the object displayed in the row that the user selected. Since my grid is displaying Customer objects, I can cast that Item property to a Customer object. I'll put that Customer object into a field to use in other parts of my UI:

private Customer currentCustomer;
public void DisplayDetail(GridCommandEventArgs e)
{
  currentCustomer = (Customer) e.Item;
}

By default, the grid is also going to put the row I selected into an edit mode. To prevent that from happening, I set GridCommandEventArgs.IsCancelled to true, which prevents the selected row's display from changing. At this point, then, my DisplayDetail method looks like this:

public void DisplayDetail(GridCommandEventArgs e)
{
  currentCustomer = (Customer) e.Item;
  e.IsCancelled = true;
}

My next step is to display the information from the row in a form rather than as a row in a grid. To handle that, I'm going to take advantage of the TelerikTabStrip.

Configuring Tabs

What I'm going to do is set up two tabs within the TelerikTabStrip: one tab to display the grid, and one to display the data from the selected row.

Moving my grid into a tab is easy: I just wrap my grid's markup inside a <TelerikTab> element inside a TelerikTabStrip. I'll use the TelerikTabStrip's TabPosition attribute to have the tabs display across the top of my page. I'll also add a second tab to display the individual customer. With both tabs, I'll use their Title attribute to set the text displayed in at the top of the tab:

<TelerikTabStrip ref="@tabstrip" TabPosition="TelerikTabPosition.Top">
  <TelerikTab ref="@currenttab" Title="Customer List">
    <TelerikGrid Data="@customers">
      <!-- grid markup -->
    </TelerikGrid>
  </TelerikTab>
  <TelerikTab Title="Current Customer">
    <!-- markup to display the selected customer -->
  </TelerikTab>
</TelerikTabStrip>

Initially, I want the “Current Customer” tab to be disabled and enabled only after a customer is selected. To handle enabling/disabling the tabs, I'll need to bind the tab's Disabled attribute to some field or property I can set from code. I'll call this field currentCustomerTabDisable:

private bool currentCustomerTabDisable = true;

Now, in my DisplayDetail method's code, after retrieving the selected Customer, I set the field to false:

public void DisplayDetail(GridCommandEventArgs e)
{
  Customer cust = (Customer) e.Item;
  e.IsCancelled = true;
  currentCustomerTabDisable = false;
  StateHasChanged();
}

Of course, this won't do any good unless I also tie the Disabled attribute on my tab to the field. That markup looks like this:

<TelerikTab Title="Full Customer"
          Disabled="@currentCustomerTabDisable">
  <!-- ... -->
</TelerikTab>

Displaying the Selected Customer

Having gone to all that trouble, the final step is to display the selected Customer's information in the second tab. That's “plain old Blazor code”: I add some textboxes to the second tab and use the bind attribute to associate the textbox with my currentCustomer field. That markup looks like this:

<TelerikTab Title="Full Customer"
          Disabled="@currentCustomerTabDisable">
  <input type="text" bind="@currentCustomer.FirstName" />
  <input type="text" bind="@currentCustomer.LastName" />
</TelerikTab>

Because the bind attribute implements two-way databinding, changes made on the “current customer tab” are automatically reflected in the grid.

Of course, if I was a decent human being, I wouldn't just enable the “current customer tab”, I would also switch the user to that tab. I can do that by calling the SetActiveTab method, passing a reference to the tab I want to display. However, to access the tabstrip (so that I can call its SetActiveTab method) and the tab (so I can pass it to the SetActiveTab method), I first need references to both. That's a three-step process.

First, I add the ref attribute to the <TelerikTabStrip>, tying it to a field in my function's block called I've called “tabStrip”:

<TelerikTabStrip ref="@tabStrip" TabPosition="TelerikTabPosition.Top">
  <!-- ... -->
</TelerikTabStrip>

In the same way, this markup ties the tab to a field called currentCustomerTab:

<TelerikTab ref="@currentCustomerTab"
          Title="Full Customer"
          Disabled="@currentCustomerTabDisable">
  <!-- ... -->
</TelerikTab>

The second step is to add those fields to my functions block. A TelerikTab implements the ITab interface, which suggests that there may be multiple kinds of tabs in the future. To support that possibility, I declare my currentCustomerTab as an ITab:

@functions {
  private TelerikTabStrip tabStrip;
  private ITab currentCustomerTab;
  // ...
}

With those references to the TelerikTabStrip and TelerikTab in place, I can update my DisplayDetail method to switch the user to the second tab:

public void DisplayDetail(GridCommandEventArgs e)
{
  currentCustomer = (Customer) e.Item;
  e.IsCancelled = true;
  currentCustomerTabDisable = false;
  tabStrip.SetActiveTab(currentCustomerTab);
  StateHasChanged();
}

One of the nice features of this design is that it's almost infinitely extensible: As you add more customer-related functionality to this page, you can just keep adding more tabs. And all it will cost you is some markup and about half a dozen lines of code.

Implementing a List/Details Page in Blazor

$
0
0

A common UI pattern is the List+Details page: The top of the page has a grid (or, perhaps, just a drop-down list); the bottom of the page has the detail for the item selected at the top of the page. An example of this pattern is a page with a list of customers at the top and a list of the currently selected customer's salesorders at the bottom.

The TelerikWindow UI component in Telerik UI for Blazor makes this pattern easy to implement. Using the window effectively separates your page into two views (the top and the bottom), allowing you to develop the bottom portion displayed inside the window independently of the top portion. The window component allows you to hide or reveal the bottom of the page, depending on what's going on in the top part. Your biggest design decision is deciding how much UI you want to put inside the window.

Setting Up the Top of the Page

As an example, I'll start with a <TelerikGrid> element at the top of my page that displays a list of customers (that list is held in a field called customers in my functions block). Inside the grid, I use the <TelerikGridCommandButton> element to put a select button on each row and tie that button to method called DisplayDetail using the <TelerikGridEvents> and <EventsManager> elements. The markup to create my grid looks like this:

<TelerikGrid Data="@customers" Sortable="true">
  <TelerikGridEvents>
    <EventsManager OnEdit="@((args) => DisplayDetail(args))"></EventsManager>
  </TelerikGridEvents>
  <TelerikGridColumns>
    <TelerikGridCommandColumn>
      <TelerikGridCommandButton Command="Edit" Icon="edit">
        Select
      </TelerikGridCommandButton>
    </TelerikGridCommandColumn>
    <!-- ... -->
  </TelerikGridColumns>
</TelerikGrid>

Following the close tag for the <TelerikGridCommandColumn> element, I put the markup that defines the few columns of key information that allow the user to identify the customer they want to see details for:

<TelerikGridColumn Field="Id" Title="Customer Id" />
<TelerikGridColumn Field="LastName" Title="Last Name" />

The next step is to load the grid with customer data when the page first displays (I'm retrieving the data from a service endpoint in this code):

@functions {
  private IEnumerable<Customer> customers = null;

  protected override Task OnInitAsync()
  {
    HttpClient hc = new HttpClient();
    HttpResponseMessage rm = await hc.GetAsync("https://localhost:5001/customers");
    customers = await rm.Content.ReadAsAsync<IEnumerable<Customer>>();
    StateHasChanged();
    return base.OnInitAsync();
  }
}

With the top (List) part of the pattern in place, I can use the TelerikWindow to implement the bottom (detail) part.

Setting Up the Bottom of the Page

Initially (and until the user selects a customer in the grid), the window that displays the details is unavailable, so I've started by setting the TelerikWindow's Visible attribute to false:

<TelerikWindow Visible="false">
  <!-- ... -->
</TelerikWindow>

You can add additional attributes to the TelerikWindow element to control the window's location and size. The Size attribute, for example, will accept a value from the Size enumeration to use one of three standard sizes (Large, Medium, and Small). Alternatively, you can create a custom size by adding the Height and Width attributes to the element. In the absence of any of those attributes, the window is automatically sized to be just big enough to hold its content.

You can also set the TelerikWindow's Centered attribute to true to have the window centered in the browser window (not within the window's container). For custom positioning, the TelerikWindow's Top and Left attributes allow you to put the window wherever you want (within the browser's window, of course). Without the Centered, Top, and Left attributes, the window will display where it would appear in the “normal flow” of the page.

Wiring Up the Select Button

The next step is, in my DisplayDetail method, to activate the window and retrieve the data to be displayed in the window when the user selects a row. I first need to add two using statements at the top of the page to make the code work:

@using Telerik.Blazor
@using Telerik.Blazor.Components.Window

My DisplayDetail method, called from the grid, will automatically be passed a GridCommandEventArgs parameter that has two key properties: Item and IsCancelled. The Item property holds a reference to the Customer object displayed in the selected row; the IsCancelled property allows me to suppress the default behavior for the button (which is to switch the row out of display mode and into edit mode).

In the DisplayDetail method, I just want to move the selected Customer object into a field or property so that I can bind UI elements inside the window to properties on the Customer object. I also need to set the IsCancelled property to true to keep the row from being put into edit mode. That code looks like this:

@functions {
  private Customer currentCustomer;
    
  public void DisplayDetail(GridCommandEventArgs e)
  {
    currentCustomer = (Customer) e.Item;
    e.IsCancelled = true;

    // ...
  }
}

Of course, rather than display more information from the Customer object, I could retrieve other, related information – the sales orders for the customer or a list of shipments, for example.

Now that there's data to display, I need to make the window visible. The first step in that process is to tweak the TelerikWindow's Visible attribute so that it's bound to a field or property in my functions block. The enhanced markup looks like this:

<TelerikWindow Visible="@windowVisible">
  <!-- ... -->
</TelerikWindow>

Inside my page's functions block, I need to define the windowsVisible field:

@functions {
  private bool windowVisible;
  private Customer currentCustomer;

  // ...
}

Now, to make the window visible, I just need to set that windowVisable field to true and call Blazor's StateHasChanged method to let Blazor know that the page needs to be updated. I'll do that at the end of my DisplayDetail method:

public void DisplayDetail(GridCommandEventArgs e)
{
  currentCustomer = (Customer) e.Item;
  e.IsCancelled = true;
  windowVisible = true;
  StateHasChange();
}

Adding Content to the Window

With the top and bottom of my page defined (and their interaction), all that's left is to add content to the window. I add that content inside <TelerikWindowContent> elements inside the <TelerikWindow> element.

The following markup adds a textbox element that, using Blazor's bind attribute, implements two-way databinding between the textbox and the FirstName property on my currentCustomer object (i.e. changes to the property change the value in the textbox and changes to the value in the textbox automatically update the property). The content also includes a button that the user can click to save the changes made to that customer object through the textbox:

<TelerikWindow Visible="@windowVisible">
  <TelerikWindowContent>
    First Name: <input type="text" bind="@currentCustomer.FirstName" />
    <!-- more input elements to display/update Customer properties -->
    <input type="button" onclick="SaveCustomer" value="Save Changes" />
  </TelerikWindowContent>
</TelerikWindow>

I could also have added the <TelerikWindowTitle> element inside the <TelerikWindow> element to define a header for my window.

In the SaveChanges method called from my button, I need to do a few things. First, of course, I need to send the updated currentCustomer to the service endpoint I retrieved it from in order to update the data at the service. After that, I set the field that controls my window's visibility to false and set the currentCustomer field to null. The grid will take care of displaying the changed data so I don't need to call StateHasChanged to update the display with the changed data:

public async void SaveCustomer()
{
  HttpClient hc = new HttpClient();
  HttpResponseMessage rm = await hc.PutAsJsonAsync("https://localhost:5001/customers", 
                                                   currentCustomer);
  currentCustomer = null;
  windowVisible = false;
}

From this point on, it's just a matter of how complicated I want the bottom part of my page to be. If I want to have multiple, related views of detail data, I might add the TelerikTab control inside of my window to organize those views. If different kinds of data in my grid required different views, I might add multiple windows to my page and choose which one to make visible in my DisplayDetails method.

The key takeway is that, with this structure in place, extending this UI pattern just depends on what content you want to put in your windows and how many windows you want to include in your page.

The full download of this project is available here.

.NET Developer Updates from Build 2019

$
0
0

Coming out of Microsoft Build, let us recap the most exciting platform updates and tooling enhancements for .NET developers.

Microsoft just wrapped up its annual Build developer conference in Seattle last week. Build has always been future-facing, showing developers a glimpse of what's possible with modern tooling. Microsoft also deeply cares about developer experiences through rich tooling and longevity of developer platforms. There was much to rejoice from Build 2019 - a cornucopia of announcements of interest to most .NET developers. Let's take a look at some exciting developments enabling .NET developers to build the next-generation of amazing apps.

Visual Studio

Visual Studio, in its various forms, provides one of the richest experiences for developers. VS really is a cutting-edge IDE enabling top-notch developer productivity for building any type of app - web, desktop, mobile, cloud or AR/VR, across a variety of programming languages. It is no surprise that Visual Studio continues to get love and investments to empower developers.

VS2019 

VS IntelliCode

Visual Studio's IntelliCode is essentially AI-assisted enhanced IntelliSense. IntelliCode recommends what developers may be intending to type at the top of your completion list - these recommendations are based on thousands of open-source projects on GitHub. When combined with local code context and customizations to promote common practices, IntelliCode promises a ton of developer productivity help. IntelliCode’s capabilities for assisted IntelliSense are now generally available for C#/XAML in Visual Studio and Java/JavaScript/TypeScript/Python in Visual Studio Code.

VS Code Remote Developer Extensions

Visual Studio Code now enables superior remote development scenarios, thanks to new Extensions. Developers can now write/edit/debug code on remote machines/servers, virtual machines and Docker containers. In the time of increasing implementations of Cloud Native architectures, Remote Developer Extensions for VS Code should provide more ammunition and flexibility for developers to be successful.

VS Online

Did you know VS Code is essentially a web app running inside an Electron shell? The same rich code authoring experience offered by VS Code will now be available to developers through the browser. While online code editing was already available for Azure hosted projects/solutions, VS Online will make the experience ubiquitous as a companion to Visual Studio and Visual Studio Code. Built for productivity on the go, VS Online will enable developers to pull up any modern browser and have access to their code. VS Online allows for quick code edits, Pull Requests and even joining Visual Studio Live Share sessions.

.NET

The beloved .NET continues to evolve, supporting ever increasing platforms and programming paradigms. .NET promises a more unified framework over fragmentation, while enabling app modernization and infusing intelligence into apps.

DotNet5 

.NET 5

The promise of One .NET is here - the next iteration will just be called .NET 5 arriving in 2020. This would be a unified .NET stack - combining the best .NET Core and Mono. Developers can think of .NET 5 as a unified single Base Class Library containing APIs for building any type of application - ASP.NET web apps, Xamarin apps for iOS/Android/other platforms, Windows Desktop and IoT. .NET 5 will provide both Just-in-Time (JIT) and Ahead-of-Time (AOT) compilation models to support multiple compute scenarios for both server-side and thin clients.

.NET Core 3

While .NET 5 is out on the horizon, the next iteration of .NET Core 3 is Preview 5 available now. .NET Core 3 brings modernization to Windows Desktop development, enabling access to new APIs and side-by-side .NET runtimes. Both WinForms and WPF apps can now be built on top of .NET Core 3, as well as enabling ASP.NET server-side Blazor apps with C#/Razor syntax.

.NET for Apache Spark

Apache Spark is a unified analytics engine for large-scale data processing. Spark runs on Hadoop, Apache Mesos, Kubernetes, standalone or in the cloud, and can access diverse data sources. A new OSS library adds .NET support to Apache Spark, enabling developers to build solutions with Spark without having to revert to other programming languages.

Xamarin.Forms 4.0

The next release of Xamarin.Forms promises a new era of productivity for developers building cross-platform mobile apps. Xamarin.Forms 4.0 introduces the Shell - a new way to structure apps. Xamarin.Forms Shell provides full-featured navigation out of the box with flyout menus, bottom/top tabs and URI-based routing. The new Xamarin.Forms Visual NuGet package offers developers an easy way to implement Material Design for app-wide consistency and also the option to customize the Material renderers.

ML.NET 1.0

If developers had any doubts about the importance of Machine Learning going forward, it is now built into .NET. ML.NET is an OSS cross-platform framework that runs on Windows, Linux and macOS, making machine learning accessible within .NET. Developers can now build and infuse custom AI into their applications by creating custom machine learning models. This should enable the next generation of intelligent .NET apps capable of ML tasks such as classification, regression, clustering, ranking, recommendations and anomaly detection. ML.NET is now generally available with the first production-ready 1.0 version.

Mixed Reality

One Build keynote demo failure aside, AR/VR pushes the boundary of human-computer interactions and enables new immersive experiences.

Holo2 

Hololens 2 Developer Edition

Hololens 2 is amazingly cool and addresses a lot of the shortcomings of the Generation 1 Hololens. While MR/VR/AR offer opportunities for developers, a stumbling block has been the high barrier to entry, arguably the cost factor of Hololens. Hololens 2 Developer Edition looks to offer a solution - thus making it easier for developers to jump into building Mixed Reality apps and experiences for Hololens 2. The development edition includes a HoloLens 2 device, Azure credits, Unity Pro trials and other tools - all for $99 per month.

Unreal Engine

Unreal Engine is the uber popular gaming engine allowing for ambitious artistic visions to be brought to life, thanks to a full product suite of creativity tools. Unreal Engine support for streaming and native platform integration will be available for HoloLens 2 - this is big news for developers aiming to bring amazing Mixed Reality experiences on the Hololens 2.

Windows for Developers

While the modern Microsoft is all about open source and cross-platform parity, the desire remains for Windows OS to be home for developers. As the push for unified Windows apps evolve, there is increasing parity between Win32 and UWP stacks, as well as modern tools providing developer flexibility.

WindowsTerm 

Windows Terminal

After what feels like eternity, the terminal in Windows is getting some love back. Windows Terminal promises a new terminal experience for CLI developers on Windows. As expected from a modern terminal application, Windows Terminal will sport support for GPU accelerated text rendering, multiple tabs and the all-important emoji support. Windows Terminal is slated to arrive sometime in June.

React Native for Windows

Using React to build web apps or React Native to target mobile form factors? There is good news if developers want to target the Windows App Store. The same component model architecture and coding experience/artifacts can now be reused to make native apps for Windows - thanks to React Native for Windows. No longer a PWA shell, React Native can be used to build performance-tuned native Windows apps.

Conclusion

Build 2019 was a milestone event allowing Microsoft to share its tech vision with developers. While Cloud and AI dominated the overall tech landscape, practical developer tooling enhancements and updates to existing frameworks keep inviting developers to the Microsoft technology stack.

As always, we at Progress are here to clear roadblocks for developers to be successful. With Telerik and Kendo UI, we’ll continue to provide rich UI controls and frameworks to light up your Web/Mobile/Desktop apps. Hot off the press is Telerik UI for Blazor - Blazor web components written from ground up for server-side or client-side use. And we support Telerik UI for WinForms/WPF on .NET Core 3 already. With an eye towards the future, close partnership with Microsoft and heavy investments to make top notch developer tooling, needless to say - we’re here for you, today and tomorrow.

WebAssembly-ifying .NET with Blazor

$
0
0

WebAssembly is one of the newest technologies to hit the web dev world with some promising new features around performance and expanding the boundaries of web languages. We’ll take a look at using it with Blazor to allow .NET developers to create a SPA.

WebAssembly allows you to execute code built in other languages within the browser. Traditionally, writing a web app with .NET would involve ASP.NET with an IIS server. With the introduction of WebAssembly, new frameworks are being developed to allow new languages to start being web languages by being compiled down into WebAssembly. In this article, we will explore one of those frameworks: Blazor. Blazor allows .NET developers to write .NET code to create a SPA (Single Page Application). Since every new language brings a new perspective, it'll be interesting to see how a new wave of .NET developers shape SPA designs and patterns going forward.

Microsoft is definitely starting on the right foot with Blazor by providing an easy way to get started along with some boilerplate code. We are going to explore a little of what makes Blazor unique. Then, we are going to create our site and get it ready to be hosted. The source code for this article is available on GitHub: BlazorEx.

Let's jump into it.

What is Blazor?

Like I mentioned earlier, Blazor is a SPA framework that can be compiled down to WebAssembly and run in a browser. At this time, Blazor comes in two flavors: server-side and client-side.

Server-side Blazor is very similar to traditional ASP.NET, but uses SignalR to communicate between client and server and needs to be hosted from an IIS server. This flavor of Blazor has all the ups and downs of ASP.NET — a server is managing multiple client connections, and the bundle cannot be hosted via CDN. Server-side Blazor is expected to shift with .NET Core 3.0 later this year.

Client-side Blazor, which I'm just going to refer to as Blazor from this point forward, allows the bundle to be hosted from a static location, which offloads work from the servers. This flavor of Blazor has recently moved from experimental to official preview status. Blazor accomplishes browser compatibility for C# by compiling down code into .NET assemblies, which are converted into WebAssembly.

While Server-side and Client-side Blazor share the same programming model, client-side Blazor will not ship with .NET Core 3.0 on initial release, but it has been committed to shipping out in a future release of .NET Core 3.0.

Setting Up an Environment for Blazor

We are going to need to download some new tooling. Due to Microsoft's push towards .NET Core, this post is not limited to those with Windows; all types of operating systems can participate. I'll include notes for each OS where it differs from the others.

  1. Download Visual Studio 2019 (macOS and Windows only)
  2. Download the latest .NET Core 3.0

    Follow the directions for your OS in the link. After this step, you should be able to run dotnet --list-sdks from your Terminal or Command Prompt to see .NET Core 2.1 (if you downloaded Visual Studio) and 3.0.

  3. Get the templates for Blazor by running the following command in your Terminal or Command Prompt to download the templates:
    dotnet new -i Microsoft.AspNetCore.Blazor.Templates::0.9.0-preview3-19154-02
  4. If you run into any problems, you can see all dotnet templates where you can download the latest Blazor templates.

At this point, we should have everything we need installed to create our app.

Creating Our App

First, we need to create our app. In your Command Prompt or Terminal, run:

dotnet new blazor --name BlazorEx --output BlazorEx

This command will create a new Blazor project named BlazorEx and place it in a new folder called BlazorEx.

macOS Note: After creating a Blazor app, you need to initialize an ASP.NET Core 3.0 app (ASP.NET Core Web App) using dotnet new webapp, then dotnet run. There is a bug where a Blazor app will not run due to missing dependencies, which are installed if you run any other project first.

While inside the BlazorEx folder, run:

dotnet run

To start the app. If you navigate to http://localhost:5000, the following page is displayed:

Homepage of Blazor Application

We have built our foundation from which to start exploring Blazor at this point. In the next section, we are going to start adding new content.

Modifying Our App

This foundation for our Blazor app is a good start, but we are going to keep the momentum going by adding a profile page. The .cshtml pages contain Razor components, so if you are looking for further guides into check out this resource.

First, we need to create a Profile.cshtml in the folder, BlazorEx/Pages:

@page "/profile"
@inject HttpClient Http

<h1>Profile</h1>
<p>Pulling data from another API.</p>

@if (currentProfile == null)
{
  <div>Loading...</div>
}
else
{
  <div>
    <span>First Name:</span>
    <span>@currentProfile.Name</span>
  </div>
  <div>
    <span>Last Name:</span>
    <span>@currentProfile.Surname</span>
  </div>
  <div>
    <span>Region:</span>
    <span>@currentProfile.Region</span>
  </div>
}

@functions {
  // data retrieved from HTTP GET request
  ProfileData currentProfile;

  protected override async Task OnInitAsync()
  {
    currentProfile = await Http.GetJsonAsync<ProfileData>("https://uinames.com/api/?&amount=1&ext");
  }

  // parsed response data
  class ProfileData
  {
    public string Name { get; set; }
    public string Surname { get; set; }
    public string Gender { get; set; }
    public string Region { get; set; }
  }
}

After adding the profile page, you'll need to restart the app for the profile page to be accessible. Afterward, you'll be able to navigate to it via http://localhost:5000/profile. Next, we'll modify our NavBar to add this link.

Open up the file, BlazorEx/Shared/NavMenu.cshtml. We are going to add another entry to point to our profile page in the Navigation Bar.

<li class="nav-item px-3">
  <NavLink class="nav-link" href="profile">
    <span class="oi oi-person" aria-hidden="true"></span> Profile
  </NavLink>
</li>

Restart the service, and you'll see a new link on the left side of the page:

Image of Working App on Profile Page

Hosting

One of the primary benefits of Blazor is being able to host our app as a static file, but up to this point, we have been using dotnet run to serve it up locally using .NET. Let's package up our project and get it ready to be hosted from as a static file.

First, we need to publish it in release mode.

dotnet publish -c Release

Next, you want to copy the build artifacts into a more manageable location.

cp -av ./bin/Release/netstandard2.0/publish/BlazorEx/dist/. ./build

Depending on where you want this hosted, you'll need to change the <base> tag in the index.html. If you want to host it from a custom domain, you can delete the tag. If you are going to host it from a specific path (i.e. https://reedyrm.github.io/BlazorEx/), you will need to specify that path in the href attribute of the base tag.

<base href="https://reedyrm.github.io/BlazorEx/" />

Finally, let's test this locally to verify that everything is being built correctly. We can install a static file hoster called serve.

yarn global add serve

Next up, you can run the following command and navigate to the URL to see the site hosted.

serve -s build

You should be able to view it locally.

Now you're all set to keep building your new site or to start migrating over some functionality from your existing ASP.NET app. Some of your components may be close to a simple copy & paste to get them working in Blazor.

Conclusion

We have walked through Blazor as a concept, jumped into getting our environment setup, made some changes, and finally got it ready to be hosted. While this framework is still in development, Blazor elevates .NET to the same tier of languages like Node which allow developers to have the same frontend and backend languages.

As a whole, WebAssembly has started opening the doors of web dev by allowing new languages (.NET and Rust) to be web languages. WebAssembly has even found its way into other non-web environments like IoT devices and server execution. It'll be exciting how you use it in your ecosystem.

Looking to Create Beautiful UI with Blazor?

Don't forget to check out the new Telerik UI for Blazor, our native UI component suite for the Blazor framework. Get up and running quickly with grids, charts, calendars and much more. You can start a free trial today.

Learn More about Telerik UI for Blazor

Start a Free Trial Today


Telerik and Kendo UI R2 2019 Release is Here!

$
0
0

The second Telerik and Kendo UI release of the year has arrived! Check out the all-new and first-to-market Telerik UI for Blazor, and learn everything that's new, including new components and hundreds of improvements!

Every day as we open the telerik.com home page, we are reminded of the goal we are pursuing—to make Modern UI easy for you. On the web, on desktop and on mobile, with your framework and programming language of choice. Enabling you to be the best developer you can possibly be.

Our second release for 2019 delivers precisely on this goal by providing support for the latest technologies for building applications. We are excited to introduce the GA release of the all-new Telerik UI for Blazor component suite, packed with more than 16 native components. In addition, we are also happy to announce support for Visual Studio 2019 and .NET Core 3.0, numerous new controls and improvements across all frameworks and platforms. Read on for more details, and for those of you who just want to get the bits right away, you can get them here.

First to Market with Telerik UI for Blazor

If you haven’t heard of Blazor, you should really check it out. Blazor started as an experimental .NET web framework embracing WebAssembly to target web applications using C# and HTML. Your C# compiles to WebAssembly, so no need for JavaScript!

As one of the first teams to throw our support behind this new Microsoft framework, we want to help Blazor mature faster and ensure the ecosystem around it is ready for all of you who are as passionate about Blazor as we are.

We are so proud thatTelerik UI for Blazor 1.0.0 is here! With the initial release we have the following UI components ready for you right out of the box.

  • Grid
  • Area, Column, Bar, Line, Pie, Donut Charts
  • Calendar
  • Date Input and Date Picker
  • DropDownList
  • Numeric Textbox
  • Button
  • TabStrip
  • TextBox
  • Window
  • Animation Container

That’s a huge number of components! And all of them are native to the Blazor framework, so no funky business with wrappers. After a lot of research we decided to build the components natively in order to take full advantage of the framework capabilities and not make any sacrifices in terms or performance or functionality. With this list you can already start developing pretty advanced applications using Blazor. Needless to say, more components will be coming as soon as they are ready.

All of the input components can take advantage of Blazor’s validation framework and there’s full support for templates across the board.

One of the heavier hitters here is obviously the native Grid component. Just as a quick highlight, here are the initial features we have managed to squeeze in to the Grid (with more to come of course).

  • Paging
  • Sorting
  • Filtering
  • Show/Hide Columns
  • Cell Templates
  • In-cell Editing
  • Inline editing
  • Popup Editing
  • Custom form for editing
  • Custom editor (editor templates)

There’s just so much to showcase in the new Telerik UI for Blazor, so if you want to deep dive into it you can easily do it now.

If you’ve already been using Telerik UI for Blazor in its earlier iterations, you can go over to our What’s New in Telerik UI for Blazor 1.0.0 page to see what’s changed.

Blazor at Build

What’s New in the Telerik Line of Products

The R2 2019 release formalizes our support for Visual Studio 2019 and .NET Core 3.0, and brings a bunch of new controls for your web, mobile and desktop applications. While not a comprehensive list, below are our Telerik release highlights. Make sure you check out the release notes and blogs (see the table below) for each product to learn about everything that is included.

Web

  • Telerik UI for ASP.NET Core—Now features official support for .NET Core 3.0 preview 4
  • Telerik UI for MVC and Telerik UI for ASP.NET Core - New PDFViewer component, ListView endless scrolling, Spreadsheet and DataRangePicker improvements, as well as adaptive rendering for Grid and Scheduler
  • Telerik UI for AJAX—Updates to the MultiColumnComboBox and Button controls as well as plenty of stability improvements 

Mobile—Telerik UI for Xamarin

  • Brand New Controls: Map and Image Editor
  • Introducing a new document processing library for creation and manipulation of PDF documents—PDF Processing
  • The PDF Viewer component is now official, polished and packed with features 
  • Visual Studio 2019 for Mac Support

Desktop—Telerik UI for WPF and WinForms

  • Telerik UI for WPF & WinForms Visual Studio templates for .NET Core apps
  • Simplified Ribbon for WPF and WinForms
  • New TabbedWindow & WebCam controls for WPF
  • New DomainUpDown control and Customizable File Dialogs for WinForms

Reporting, Testing & Productivity Tools

  • PDF documents accessibility and new JSON DataSource component for Telerik Reporting and Telerik Report Server
  • WPF & WinForms report viewers support for .NET Core 3.0 for Telerik Reporting
  • Implement support for Azure DevOps pipeline with build agent hosted in the cloud, verification of method call prerequisites, automatic resolving of test context when using asynchronous tasks for Telerik JustMock
  • Visual Studio 2019 support for Telerik Test Studio Dev Edition 

What’s New in the Kendo UI Line of Products

The R2 2019 release adds a slew of new Kendo UI controls, numerous grid improvements, and rounds out Kendo UI’s native support for three of the most popular JavaScript frameworks (React, Angular and Vue). Be sure to check out the release notes and blog posts (see the table below) for more info.

KendoReact

    • New native components available with this release: Sortable component, Drag & Drop component, Native DateTimePicker component, Native Notification components
    • New Native Editor component - KendoReact rich text Editor is a full-featured, highly customizable WYSIWYG editor
    • Enhancements to existing components, like: Column virtualization and context menu in the Grid, Drag & drop and selection support in the TreeView

Kendo UI for Angular

A large list of Scheduler enhancements and features, including drag & drop, resizing of events and export to PDF

  • The official v1 release of the rich text Editor, including a whole slew of new tools like inserting images and files, font pickers, formatting drop downs and localization just to name a few
  • Grid enhancements including infinite scrolling, cell spanning and more
  • The DropDown components have added virtualization for high-performance scenarios
  • New color palette and color picker component
  • Additional accessibility features to help ensure compliance with WCAG 2.1

Kendo UI for Vue

  • Native Vue Grid enhancements including grouping virtualization, locked columns and column menu
  • The ListView component added the top-voted feature: Endless scrolling
  • New border radius options for ThemeBuilder

Kendo UI for jQuery

  • New PDF Viewer component
  • Spreadsheet enhancements including paste-value, add images, comments and row height autofit
  • Grid enhancements including adaptive grid rendering
  • The ListView component added the top-voted feature: Endless scrolling
  • Enhancements for mobile support including adaptive rendering for the scheduler, and full mobile support for the DateRangePicker
  • Menu component integration with the DataSource
  • New border radius options for ThemeBuilder

You can find out more details on all this at the Kendo UI release blogpost.

R2 2019 Release Blog Posts

While this blog post provides a high-level overview, you will want to check out these in-depth blog posts which cover all new features in detail. (Note: links will be updated as they go live.)

Kendo UITelerik Reporting & Mocking 
KendoReactTelerik UI for ASP.NET MVCTelerik Reporting and Report Server 
Kendo UI for AngularTelerik UI for ASP.NET Core Telerik JustMock 
Kendo UI for VueTelerik UI for ASP.NET AJAX 
Kendo UI for jQueryTelerik UI for Xamarin 
 Telerik UI for WinForms  
 Telerik UI for WPF 

 

Your Feedback Matters!

We’d appreciate you pulling our new release today and sharing your feedback at https://feedback.telerik.com to help us shape the future of our Telerik and Kendo UI line of products.

Sign Up for Release Webinars

Seeing is believing, so register to see all the new features—WEBINARS ARE COMING UP FAST! It will help you to follow along easily if you download the latest release here.

Telerik Webinar

Date/Time:  Wednesday, 29 May 2019, 11 a.m. – 12 a.m. ET

Register for the Telerik Webinar

KendoReact

Date/Time: Tuesday, 4 June 2019, 11 a.m. – 12 a.m. ET

Register for the KendoReact webinar

Kendo UI

Date/Time: Thursday, 6 June 2019, 11 a.m. – 12 a.m. ET

Register for the Kendo UI webinar 

JustMock in the Cloud, New Features for Async Tasks and More with R2 2019

$
0
0

Following your requests for JustMock, with R2 2019 we provide support for Azure Pipeline with build agent hosted in the cloud, auto resolving of test context when using asynchronous tasks, verification of method call prerequisites, throw an exception from an asynchronous task and new .NET Core project templates for Visual Studio.

Support for Azure Pipeline with Build Agent Hosted in the Cloud

Until now JustMock supported Azure Pipeline with build agent hosted on premises server. This was a limitation due to the requirement JustMock to be installed on the server. With R2 2019 we are officially providing installation free option for the Azure Pipeline task.

The installation free option is available for build agents hosted on premises servers and in the cloud. To configure this new option go to the JustMock options section in the JustMock VSTest task, which you should add to your build pipeline after installing our Telerik JustMock Tests v.2 extension. Simply fill the 32 and 64 bit JustMock profiler path as it is done in the following screenshot:

Azure Pipeline

 

Of course, you should first make sure that the 32 and 64-bit JustMock profiler dlls are available on the build agent machine. I have personally done that by adding them to the source control in a separate folder named "Lib". This way I ensure that regardless if the build agent is on premisses or in the cloud the profilers dll will be available. Lastly, a verification of the correctness of the specified path is always a good practice.

Support for Verification of Method Call Prerequisites

There are those test cases where the developer should make sure that a certain number of methods were already executed before verifying that a particular method has returned a correct value. This is why we have implemented a new feature for verification of method call prerequisites.

To better illustrate the benefit of this feature I will give the following example. Imagine that you want a certain collection to be returned by a method only after an Init method is called for all elements in that collection. How would you verify that?

Here is a code example demonstrating exactly how this test case could be verified:

// Arrange
var barCollection = newList<IBar>()
{
    Mock.Create<IBar>(),
    Mock.Create<IBar>(),
    Mock.Create<IBar>()
};
var barContainer = Mock.Create<IBarContainer>();
Mock.Arrange(() => barContainer.Elements)
    .ReturnsCollection(barCollection)
    .AfterAll(barCollection.Select(bar => Mock.Arrange(() => bar.Init())).ToArray());
 
// Act
barCollection.ForEach(bar => bar.Init());
var actualCollection = barContainer.Elements;
 
// Assert - verify that all prerequisites are met
Mock.Assert(barContainer);

For more information please check our documentation article about this feature.

Auto Resolving of Test Context When Using Asynchronous Tasks

In many situations when creating a mock for a static member the developer writing the test should think if this static member can be called from an async task and search for the correct JustMock API to handle this scenario. Until now the arrangement of such static member had to be done with calling the OnAllThreads method after all other expectations. With R2 2019 we have simplified this process by implementing an automatic resolving of test context when using asynchronous tasks. This means that if the developer has made an arrangement for a static member or future creation of object instance those arrangements will be valid out of the box for all async tasks created by the test method. 

Throw an Exception from an Asynchronous Task

Have you ever wonder how to simulate the return of a failed asynchronously executed task with specific exception? Me too as so do our clients. This is why we have implemented support for throwing a specified exception for a target asynchronous call causing returned task to fail. Here is example of how such arrangement should be done:

Mock.Arrange(() => foo.AsyncExecute()).ThrowsAsync<ArgumentException>();

For more information please check our documentation article about this feature.

.NET Core Project Templates

As we promised we are adding .NET Core project templates for Visual Studio. With those project templates a developer could create a test project for .NET Core using JustMock with few clicks.

Net Core test project template

Sign Up for the Webinar

To see the new release in action, please join us on the Telerik R2 2019 webinar, on Wednesday, May 29th @ 11:00 am - 12 pm ET.

Save My Seat

Share Your Feedback

Feel free to drop us a comment below sharing your thoughts. Or visit our Feedback portal and let us know if you have any suggestions or if you need any particular features.

Try out the latest:

JustMock

In case you missed it, here are some of the updates from our previous release.

What's New in Telerik Reporting and Telerik Report Server R2 2019

$
0
0
Our second release is here, and we are excited to share all the latest updates across Telerik Reporting and Telerik Report Server. Check out how to generate PDF documents with all applicable accessibility standards, fetch JSON-formatted data or how to use desktop viewers in .NET Core applications. 

The next major versions of Telerik Reporting and Telerik Report Server products have been just published. Now, it's time to introduce the latest features and improvements packed into the R2 2019 release. 

Here’s a quick look at the things we are most excited about: 

PDF Documents Accessibility 

As we keep striving to provide the best user experience for all end-users, it is essential that we can reach out to a wider audience. PDF export format is the most used one in our product, so in this release we decided to continue to push forward our efforts to introduce accessibility support for the exported PDF documents. This improvement is especially important for organizations who broadly use this format like banks, government institutions and big enterprises, where the accessibility support is a must. This will ensure accessibility for people with disabilities who use assistive technology such as screen readers, screen magnifiers, joysticks and other technologies to navigate and read electronic content. 

PDF Accessibility

JSON DataSource Component 

As of R2 2019, we enable offline feeding of the reports with data in JSON format. The JsonDataSource component enables data items to display data stored in JSON document, including files or inline string, without writing a single line of code. Using JsonDataSource allows you to access and display data in a report without parsing the JSON document first. This adds another option of self-containing report definition that does not have external dependencies and can be easily shared for report preview and export. 

JSON Data Source

WPF & WinForms Report Viewers for .NET Core 3.0 

Following today's trends, we’ve enabled the WPF and WinForms report viewers to support the up-and-coming .NET Core 3.0. In this new Core version, Microsoft team will add support for the desktop technologies when officially released. With this and the .NET Core 3.0 support for Progress Telerik Windows Forms and WPF control suites, we enable our users to create fully featured .NET Core desktop applications. 

WPF Core Demo

Telerik Reporting REST Service Targeting .NET Core 3.0

We cannot miss to share that in this release, we’ve also improved our Reporting REST Service to support .NET Core 3.0.

Eliminated Bugs 

For the full list of all the bug fixes, check the release notes for Telerik Reporting and Telerik Report Server

Try it Out and Share Feedback 

We want to know what you think—you can download a free trial of Telerik Reporting or Telerik Report Server today and share your thoughts in our Feedback Portal, or right in the comments below.  

Tried DevCraft? 

You can get Reporting and Report Server with Telerik DevCraft. Make sure you’ve downloaded a trial or learn more about DevCraft bundles. DevCraft gives you access to all the toolsets, allowing you to say “no” to ugly apps for the desktop, web, or mobile. 

Watch the Webinars

And don't forget to look at our release webinars, where our technical experts provide a deep dive into all our new features and functionalities. 

Register for the Telerik Webinar

Register for the Kendo UI webinar 

Register for the KendoReact webinar

Simplified RibbonView, New WebCam & TabbedWindow Controls, More in UI for WPF R2 2019

$
0
0
R2 2019 of Telerik UI for WPF and Telerik UI for Silverlight is already available to download and it is fully packed with cool stuff.  We are introducing two new controls – WebCam and TabbedWindow, new Simplified View for the Ribbon control as well many new features in the Spreadsheet, TabControl and other controls.

Let’s dive into all the new controls and features of this release.

WebCam (Beta)

You wanted it – we delivered it! One of the most voted requests in our Feedback portal is now available in Telerik UI for WPF. RadWebCam allows you to easily capture photo or video and use it within your WPF application.

Here are the features of the initial version of controls:

  • Video stream– the control streams video from the connected camera.
  • Snapshot– easily take a picture by pressing camera button.
  • Snapshot preview– save or discard the taken snapshot.
  • Video recording– record video with ease by pressing the video camera button (without audio for this version).
  • Separate setting control– control the camera settings either through the built-in dialog or through separate control.
  • Localization– all the strings seen in the control are localized in all of our supported languages.

For more info check the WebCam documentation here or give it a spin through our WPF Demos! We need all of your feedback about the control, so we can better shape it (per your needs). Make sure to drop me a line here or in our Feedback portal– I will appreciate it.

Happy selfying !

Tabbed Window Control

Introducing the brand new RadTabbedWindow control. It will allow you to easily create browser-like user interface within your WPF application. You would be able to benefit from all the features of RadTabControl and RadWindow when using RadTabbedWindow.

Here are the key features of the control:

  • Pin/Unpin/Close Tabs– Pin the important tabs on the left side of the control using the respective button. Close any using the built-in close (x) button.
  • Add New Tabs - Add as many new tabs as needed at run-time using the built-in “plus” (+) button.
  • Drag and Drop– User can reorder tabs in a single window, drag out tab to create new window, or drag drop a tab from one window to another.
  • Themes– Benefit from the beauty of all the Telerik UI for WPF themes
  • CodedUI and Automation support

For more details please check this section of our online help documentation.

Simplified Ribbon

SimplifiedRibbon 

RadRibbonView now supports the modern look of the latest MS office application. Using this smaller more compact layout you could show only the common/important commands and have more space for the actual content of the application. With this modern appearance you will impress your customers and at the same time provide better user experience.

So in order to get it working just take your already built Ribbon UI and define the desired simplified UI by setting the SimplifiedItems property of RibbonTab. For more details on how to setup the Ribbon please refer to this help article.

Spreadsheet and SpreadProcessing: Scatter and Bubble charts

As promised, we continue to develop the charting functionality and with this release you can use two more chart types: Bubble and Scatter. The Scatter charts allow you to easily compare the relationship between two variables visually using two value axes. The bubbles are a different way to represent the Scatter charts and enable you to add a third value to the plotted data: the size of the bubbles.



For more info how to display charts in Spreadsheet check this article and for SpreadProcessing this article.

RadWindow Dialogs – Default Button

Have you ever wanted to change the default focused button of RadConfirm? If so – I know your pain. This is now possible without extracting and modifying its ControlTemplate – just set the DefaultFocusedButton property of the DialogParameters as shown below:

1.var dialogParams = newDialogParameters
2.{
3.    Content = "Are you sure?",
4.    DefaultFocusedButton = ResponseButton.Cancel
5.};
6.
7.RadWindow.Confirm(dialogParams);

And here is the result:

Check out the Predefined Dialogs article for more info.

.Net Core 3 Visual Studio Templates

Happy to announce that all of our Visual Studio project templates are available now as .Net Core project templates! Now with just a few clicks you could implement a rich Windows inspired application using the .Net Core version of Telerik UI for WPF. You would be able to choose from the following templates, they are available for Xaml and No Xaml binaries:

Happy coding! ‍

Other Features

  • AutomationManager: Custom AutomationProperties.HelpText will be now supported by setting the UseDefaultHelpText property to false. (link)
  • Themes: Introduced DisabledOpacity as dynamic palette resource for Windows8, Windows8Touch, Office2013, VisualStudio2013 themes.
  • GridView: New SearchMode that indicates whether an item should match any or all of the search terms. (link)
  • Map: Added option to provide API key for the OpenStreetmapProvider. The API key is needed for the Cycle and Transport modes. (link)
  • PropertyGrid: Added ability to control the initial expanded stated of the groups. (link)
  • VirtualGrid: Now if QueryableCollectionView is passed to the DataProvider the control will automatically use it instead of creating new instance.
  • TabControl: Added predefined pin and close buttons of the TabItems. (link)

Sign Up for the Webinar

To see the new release in action, please join us on the Telerik UI R2 2019 webinar, on Wednesday, May 29th @ 11:00 am - 12 pm EST.

Save My Seat

Share Your Feedback

Feel free to drop us a comment below sharing your thoughts. Or visit our Feedback portals about UI for WPFSilverlight and Document Processing Libraries and let us know if you have any suggestions or if you need any particular features/controls.

Try out the latest:

UI for WPF  UI for Silverlight


In case you missed it, here are some of the updates from our last release.

Meet Telerik UI for WinForms FileDialogs, Simplified Ribbon and DomainUpDown in R2 2019

$
0
0

Check out everything that's new in Telerik UI for WinForms with the R2 2019 release.

During the middle of the spring the new R2 2019 release is flourishing. It brings a diverse set of components, new features and amelioration in UI experience.

Let me share the key additions we have in R2 2019:

FileDialogs 

FileDialogs_WinForms

Have you ever wanted to be able to style the file dialogs in your application to appear as awesome as the controls from the Telerik UI for WinForms suite? Voilà! We are very thrilled to announce that the most wanted components by our customers are now here. You can replace the native dialogs with RadOpenFileDialog, RadOpenFolderDialog and RadSaveFileDialog to achieve a comprehensive look and feel! 

Here are a few of the major features of the dialogs:

  • Easy Navigation: The dialogs allow you to easily browse through your file system either through the tree-view-like navigation pane or the breadcrumb/path pane. A history of the visited folders is kept so that you can seamlessly jump back and forth between folders.
  • Search: The out-of-the-box search functionality allows you to quickly find just the files and folders you're looking for by using the Windows Search index when available.
  • Filter: You can specify a filter for the RadOpenFileDialog and RadSaveFileDialog dialogs in order to indicate to the user which types of files should be opened or saved.
  • Layouts: The UI allows the users to change the layout of the main pane by switching between different view modes (Tiles, Small Icons, Large Icons, etc.).
  • Variety of Themes: You can persist the appearance throughout your application by applying any of the predefined themes provided by the UI for WinForms suite to your dialogs.

Simplified Ribbon

SimplifiedRibbon_WinForms

RadRibbonBar introduces a new Simplified LayoutMode, in which all elements in the RibbonBar are automatically arranged on a single row. The simplified ribbon aims to help the user focus more on their work by providing a compact layout which is taking half the height of the standard ribbon.

DomainUpDown

DomainUpDown_WinForms

RadDomainUpDown is a combination of a text-box and a pair of arrow buttons to navigate through a predefined list of items. The control displays a text from a list of string available options. By clicking the up or down arrow button, the user can navigate backward or forward in the items list. It supports:

  • Items navigation by either using the up/down arrow keys or double clicking in the editor.
  • Data-binding - automatically populate the Items collection considering the records in the applied collection.
  • Unbound mode - adding the items manually via code.
  • Auto-complete functionality - appends text to the user's input if there is a match inside the Items collection.

Form Converter

Back in R3 2018 we introduced a RadFormConverter which is a powerful tool for converting standard forms to RadForm, RadRibbonForm and RadTabbedForm. Now, in R2 2019, if you have at least one control from the Telerik UI for WinForms suite on a Windows Forms Form, you can use the Form's smart tag to convert it to a RadForm, RadRibbonForm or RadTabbedForm.

FormConverter_WinForms

.NET Core Visual Studio Templates

Visual Studio Templates for .NET Core are introduced in the latest release. Using them, you can quickly end up with a ready to use Telerik UI for WinForms enabled application, based on .NET Core, or to jump start your project with one of the predefined application templates.

  CoreVSTemplates_01

CoreVSTemplates_02

Latest Internal Builds

We have recently released a new page on our website which will give you access to our latest internal builds. These are the distributions built automatically from our source repository and include all latest fixes (new features are usually not included). Regular builds are an integral part of our development process and based on the continuous quality assurance and feedback, we strive to produce the most stable releases possible. If you have experienced any problem with the current official distributions, there is a possibility that the issue has already been addressed in the latest internal build.

LIBs_WinForms

In addition to all these great features and new controls, as usual R2 2019 brings in many more improvements based on your feedback.

Try It Out and Share Your Feedback

R2 2019 is already available for download in customers’ accounts. If you are new to Telerik UI for WinForms, you can learn more about it via the product page. It comes with a 30-day free trial, giving you some time to explore the toolkit and consider using it for your current or upcoming WinForms development.

We would love to hear what you think, so should you have any questions and/or comments, please share them to our Feedback Portal.

Sign Up for the Webinar

To see the new release in action, please join us on the Telerik UI R2 2019 webinar, on Wednesday, May 29th @ 11:00 am - 12 pm EST.

Save My Seat

What’s New in Telerik UI for ASP.NET AJAX in R2 2019

$
0
0

The R2 2019 release for Telerik UI for ASP.NET AJAX is here! Read all about what's new in this release, including various updates to the RadMultiColumnComboBox and continued stability improvements.

May is here and you know what this means: the R2 2019 release is here! In this blog post I want to dive in to what is new for Telerik UI for ASP.NET AJAX with this new release, so let’s jump right in!

Updates to the RadMultiColumnComboBox

Some of you may have noticed that when we shipped the RadMultiColumnComboBox it had a limited set of themes that could be used with it. In terms of feedback that we received from our developers this was a fairly popular control and rather than delay a release due to the lack of certain themes we wanted to get something out in your hands right away. Well, with the R1 2019 behind is we could focus on implementing additional themes for the RadMultiColumnComboBox, which we released with R2 2019! So, if overall styling was holding you back from using the component then you have no
excused with this release!

RadMultiColumnComboBox showcasing a different theme applied to the control. 

Beyond themes we also went ahead and added several server-side events that we found to be needed for the RadMultiColumnComboBox. While we have quite a few client-side events, we wanted to expand what can be done on the server-side as well, hence the addition of the new server-side events! For a full run-down I recommend checking out our RadMultiColumnComboBox documentation section on server-side programming.

Button Gets a Confirmation Dialog

Adding an ability to work with the default browser confirm dialog, or work with the RadConfirm dialog, when using the RadButton has been one of our most requested features in our feedback portal. This can be extremely useful in scenarios where you want the user to confirm the action they’re about to do. This has technically been possible with some custom code, but now we are providing a quick and easy way to offer this with the RadButton component out-of-the-box!

Continued Stability Improvements

I always like to highlight that the UI for ASP.NET AJAX team continues to ensure that every release is the most stable release of UI for ASP.NET AJAX to date. With R2 2019 we have focused on our issues backlog and worked hard on improving the overall stability of UI for ASP.NET AJAX. This includes things like updated browser support to the latest and greatest, as well as a ton of under-the-hood items.

Upcoming Webinar

Want to see what we brought up here, plus what’s new with all of our .NET-based products? Join me and my colleagues for the official R2 2019 Telerik webinar on Wednesday, May 29th, at 11:00 AM ET! Seats are limited so make sure that you click on that link I just posted and reserve your spot today!

What's New in R2 2019 for Telerik UI for ASP.NET MVC & Core

$
0
0

The R2 2019 release for Telerik UI for ASP.NET MVC and UI for ASP.NET Core has arrived. Check out the latest and greatest including new components like the PDF Viewer and Drawer, or new features like Endless Scrolling in the ListView and data binding for the menu.

May is here and with it I bring the good news about the R2 2019 release for UI for ASP.NET MVC and UI for ASP.NET Core! These products share a lot of commonality so I wanted to cover them both in a single blog post. There’s a lot to cover here so lets jump straight in to things:

Support for ASP.NET Core 3.0 Preview 5

The first big thing that I want to announce here is that the Telerik UI for ASP.NET Core components are now compatible with ASP.NET Core 3.0 Preview 5. This ensures that those of you already looking at ASP.NET Core 3.0 can test our components in this preview version and prime us for the official release of ASP.NET Core 3.0.

New Component: PDF Viewer

UI for MVC & Core PDF Viewer component with lorem ipsum pdf content

The PDF Viewer component brand new for this release and is designed to let your users view and interact with PDF files without the need to download the file and work with it locally. The UI for ASP.NET MVC and UI for ASP.NET Core PDF Viewer be bound to a PDF file on initial load, or a user can even open a local file to view within their apps. Users can of course download the file they are currently viewing to their own machine. The UI is fully responsive and adaptive, which means the PDF Viewer works well in desktop and mobile scenarios alike.

A big item to bring up here is that the PDF Viewer comes with virtualization already in its first version! In order to make sure we can fit any high-performance scenario we wanted to make sure this was a part of our first release.

Finally, when it comes to actually processing the PDF files you have your choice of working with PDF.js or with the Telerik Document Processing Library to help process your PDF files for viewing and saving.

New Component: Drawer

UI for MVC & Core drawer widget expanded in modal mode

Another new component for R2 2019 is the Drawer widget. While this component has become a go-to for navigation across applications everywhere, just as a quick recap the drawer component is a menu that expands and collapses upon clicking a button (like a hamburger button in many mobile scenarios). Usually this is on the left or right side of the page and it provides a slick way to have navigation with minimal impact on real estate.

Showing or hiding the menu, which can be done in a modal way (overlay on top of content) or by pushing content to the side, can easily be toggled through clicking the drawer button or even through usage of our API. Each menu item comes with a default combination of a text and an icon, but you can also customize how each menu item appears through templates.

The drawer also features a “mini” mode which lets you show the drawer while only rendering the icons that you have chosen - a very compact way to add navigation to your web applications.

Big Focus on the Spreadsheet Component

A component that deserved some attention in the last couple of months was the Spreadsheet component, and with R2 2019 we are bringing a ton of highly requested features to this component.

Image Support

A long awaited feature: adding images to your Spreadsheet is now possible with R2 2019! You can add images to any cell, drag & drop the images around, and of course delete them as well. Any image(s) you add to your document will of course be exported whenever your users save the spreadsheet locally as well.

Cell Comments

This is pretty self-explanatory, but now it is possible for users to add comments in to any cells - bridging the gap even more with existing features they may have with desktop-based spreadsheet solutions.

Additional Events

This has been a big one, especially since it allows for further customization of the Spreadsheet itself. With R2 2019 we introduced a whole slew of new events:

  • Changing
  • DataBinding
  • DataBound
  • Paste
  • Cut
  • Copy

These provide a pretty solid amount of choices to ensure that you can take full control over the Spreadsheet component for ASP.NET MVC or ASP.NET Core to fit any of your application’s requirements.

Mobile & Adaptive Renderings

In order to ensure that our developers do not have to make a choice between desktop or mobile, and instead think about responsive design and Progressive Web Apps (PWAs), we’ve gone through and updated/improved the way two of our bigger components handle mobile devices. Specifically we have started to think about the adaptive rendering which is a bit different than just responsive design.

Adaptive rendering allows you to take over more of the view port and truly adapt to being on a mobile device. Rather than changing what is show or hidden when on smaller screens the component will show alternate UX in order to better suit the functionality of the components.

This has been a part of our Grid and Scheduler components for a while, but it was specifically geared towards hybrid mobile UI rather than a more modern approach of mixing desktop and mobile. So, we’ve updated things to be built-in to the components themselves (rather than rely on our hybrid UI framework) and also updated things for more modern UX design guidelines.

The Grid

Telerik UI for ASP.NET MVC & Core Grid showcasing adaptive rendering which adapts to provide a more applicable UX for mobile

Normally responsive design is brought up with the Grid we need to think about what columns to show or hide, and what other elements we can either remove or compress (pager comes down to a drop down rather than full pager, for example).

However, the Grid has filtering, sorting, user control for showing and hiding columns. All of these feature require UI elements to handle, and more often than not the desktop variations of the UX for interacting with them may be a bit clunky on mobile. Popup menus are pretty bad to deal with on mobile quite honestly. With adaptive rendering we have that in mind and we have created an alternate user experience for interactions with the Grid.

Here’s a sample of adaptive rendering in action. This is the page that appears when you tap on the header icon:

Telerik UI for ASP.NET MVC & Core Grid showcasing adaptive rendering that provides a list view with switches for column settings

Rather than another popup we now have a ListView with various options we can toggle (sorting), as well as providing switches for showing and hiding columns. Beyond this we also see with the > symbol that there is another level for filtering, which will also display a ListView of options.

A note here is that this isn’t the default behavior of the Grid. By default we assume that you want to work with responsive design. However, this type of functionality is only a configuration option away.

The Scheduler

Telerik UI for ASP.NET MVC & Core Scheduler showcasing a day view with an adapted user experience for mobile

Similar to the Grid, the Scheduler is a bigger component that can benefit from the adaptive rendering style rather than trying to squish everything in to a smaller screen.

Telerik UI for ASP.NET MVC & Core Scheduler with an agenda view adapted for mobile view ports

The image here showcases the agenda view, just one of the many views that work on mobile, with some grouping around resources. Tapping on any one of these items brings up an editable form that has a more mobile-friendly UX to help with editing on mobile devices.

Just like the Grid, this isn’t the default option. Instead this is offered through a configuration option to turn on or off.

The DateRangePicker

The DateRangePicker was added in R1 2019 and we almost immediately received feedback around what we can do for mobile devices. While it worked OK-ish, we certainly could improve. So, with R2 2019 the DateRangePicker has an improved mobile experience that should let you showcase the component on any device without concerns!

ListView Gets Endless Scrolling

Endless Scrolling continues to be a popular way of scrolling in our larger list-based components. This type of scrolling functions by loading more data once a user scrolls to the bottom of the current page, then the next set of data gets loaded. So, under the hood it operates similar to paging but to the end-user it seems like they can just continue to scroll.

The ListView is no exception to having this be a popular request, in fact it was the top-rated feature within our feedback portal until just now. With R2 2019 we can now mark this feature request as done because the ListView officially supports endless scrolling!

Miscellaneous Enhancements

Bind Menu to DataSource

With R2 2019 the Menu component supports being data bound via a DataSource! This means you can connect your menu to any back end (WebAPI maybe?) and pull in the data items from your data store.

DataSourceResult & DataSourceRequest Get Their Own Package

Previously the DataSourceResult and DataSourceRequest functionality that UI for ASP.NET MVC and UI for ASP.NET Core relies on has been built-in to the libraries. However, with these two products and our newly launched UI for Blazor all taking advantage of this code we wanted to make things a bit more modular. So, with R2 2019 we have separated out this functionality to the Telerik.DataSource package. This means you can use this whenever you are using filtering, sorting, grouping and paging on the server - all without depending on MVC.dll or Kendo.MVC.dll!

A quick note to make here is that while we recommend thinking about migrating to using Telerik.DataSource where you can, we haven’t removed the code internally to our libraries yet to ensure that we don’t introduce breaking changes!

Improved UI for ASP.NET MVC and Core Docs

We have also gone through the existing MVC and Core documentation resources and tried to update the API sections for both products. While we always try to improve documentation between every release, I wanted to especially highlight this as we spent some time on making the API of these two libraries easier to navigate through.

Upcoming R2 2019 Webinar

Want to see everything I brought up here in action? Looking for more information on other .NET UI libraries from Telerik? Well you’re in luck because on Wednesday, May 29th, at 11:00 AM ET we have the official R2 2019 Telerik webinar! Seats are limited so make sure that you click on that link I just posted and reserve your spot today!


Telerik UI for Blazor 1.1.0 Arrives!

$
0
0

The 1.1.0 release of Telerik UI for Blazor is here, providing many quality of life features and bug fixes to existing components.

The development team behind Telerik UI for Blazor is not one to sit back and relax - which is why I can announce that today we have the 1.1.0 release not even two weeks after the initial launch of 1.0.0!

This release brings some new features to existing components, as well as some bug fixes that are worth highlighting, so let’s dive right in.

Blazor Button Component

The Button component now exposes a type attribute that allows you to define different types of buttons based on your desired behavior - just like the type attribute on a regular HTML button element.

By default the Telerik UI for Blazor Button renders a <button type="submit"> element, but if you want to mix things, up as of today, we have the following options available on the ButtonType property of the component:

  • Submit - Renders a type="submit" attribute. Can submit the form and trigger validation. This is the default value.
  • Button - Renders a type="button" attribute. Does not invoke form validation and submission.
  • Reset - Renders a type="reset" attribute. Can reset the current form.

Blazor DateInput Component

The valid and invalid states of the DateInput are now triggered correctly.

Blazor DropDownList Component

The ValueField property now has a Guid property, which means that the Value and ValueField properties can now be one of hte following types:

  • number (such as int, double and so on)
  • string
  • Guid
  • Enum

We also took care of some issues we had around validation with the DropDownList.

Blazor Grid Component

With this release we took care of a couple of quality of life items for the Telerik UI for Blazor data grid. Namely:

  • The Grid’s height can now be set to 100%
  • Grid Command buttons no longer trigger form submission and validation. This improves the in-line editing experience quite a lot!
  • Grid events are now asynchronous
  • We added built-in validation to Grid Popup editor

Some of the bigger bug fixes we took care of for this release are:

  • Resolved an issue where the Grid Popup editor could appear off-screen on a vertically scrolling page
  • Grid filtering will now reset to the first page to ensure all results are properly seen (if there are any results)
  • Fixed an item where a nullable boolean property could not be edited in the Grid
  • Resolved the issue where a non-editable cell (read only) could be edited with inline edit mode

Blazor TabStrip Component

You can now access the Title property of the current active tab. So, if you have a Tab Strip defined like: <TelerikTabStrip ref="@myTabStrip">...</TelerikTabStrip> you could access the Title of the current selected tab using Console.WriteLine(myTabStrip.ActiveTab.Title);.

Interested in Blazor?

Is this the first time you’ve heard of Blazor or Telerik UI for Blazor? Well, if that’s the case then I recommend heading over to the Telerik UI for Blazor overview page to find out more! You’ll find some more information about the Blazor framework itself, as well as sing up for a trial of our UI components - all from one convenient place!

Want to Influence What’s Next?

We continue to improve and add to our list of UI components for Blazor and it’s all based off of your feedback! If there are components you wish that we would work on, or features that you want to see in existing components, feel free to comment in the section below or head over to our public feedback portal for Telerik UI for Blazor to make your voice heard!

Nine Performance Tips for Azure App Services

$
0
0

We always want the best performance from the software we deploy to Azure App Services. Not only does better performance make our customers happy, but better performance can also save us money if we “do more with less” in Azure. In this article we'll look at settings and strategies for improving the performance of web applications and web APIs running in an Azure App Service. We'll start with some easy configuration changes you can make for an instant improvement.

Enable HTTP/2

Microsoft announced support for HTTP/2 in App Services early in 2018. However, when you create a new App Service today, Azure will start you with HTTP 1.1 configured as the default protocol. HTTP/2 brings major changes to our favorite web protocol, and many of the changes aim to improve performance and reduce latency on the web. For example, header compression and binary formatting in HTTP/2 will reduce payload sizes. An even better example is the use of request pipelineing and multiplexing. These features allow for more concurrent requests using fewer network sockets and help to avoid one slow request from blocking all subsequent requests, which is a frequent problem in HTTP 1.1 that we call the “head-of-line” blocking problem.

To configure your App Service to use HTTP/2 with the portal, go to Platform Settings in the Configuration blade. Here you will find a dropdown to specify the HTTP version. With 2.0 selected, any clients that support HTTP/2 will upgrade their connection automatically.

HTTP Version Selection in App Services

HTTP/2 might not benefit every application, so you will want to run performance tests and stress tests to document your improvements. Here's a simple test where I used the network tools in Firefox against a page hosted in an App Service. The page references a handful of script and CSS resources, and also includes 16 images. Each image is over 200 KB in size. First, I used the developer tools to record what happens on an App Service using HTTP 1.1. Notice how the later requests start in a blocked state (the red section of the bars). This is the dreaded “head-of-line blocking” problem, where limitations on the number of connections and concurrent requests throttle the throughput between the client and the server. The client doesn't receive the final bytes for the page until 800ms after the first request starts.

HTTP 1.1 Blocking

Next, I switched on HTTP/2 support in the App Service. I didn't need to make any other configuration changes on the client or the server. The last byte arrives in less than 500ms. We avoid blocking thanks to the improved network utilization of HTTP/2.

HTTP/2 Improvements

In front of every Azure App Service is a load balancer, even if you only run a single instance of your App Service Plan. The load balancer intercepts every request heading for your app service, so, when you do move to multiple instances of an app service plan, the load balancer can start to balance the request load against available instances. By default, Azure will make sure clients continue reaching the same app service instance during a session, because Azure can't guarantee your application isn't storing session state in server memory. To provide this behavior, the load balancer will inject a cookie into the first response to a client. This cookie is what Azure calls the Application Request Routing Cookie.

If you have a stateless application and can allow the load balancer to distribute requests across instances without regard to previous requests, then turn off the routing cookie in the Configuration blade to improve performance and resiliency. You won't have requests waiting for a server restart, and when failures do happen, the load balancer can shift clients to a working instance quickly.

The routing configuration is another item you'll find in the Platform Settings of the App Service Configuration blade.

Turning off Instance Affinity

Keep the App Service Always On

If you've deployed applications into IIS in the past, you'll know that IIS will unload idle websites after a period of inactivity. Azure App Services will also unload idle websites. Although the unloading can free up resources for other applications that might be running on the same App Service Plan, this strategy hurts the performance of the app because the next incoming request will wait as the web application starts from nothing. Web application startup time can be notoriously slow, regardless of the technologies involved. The caches are empty, the connection pools are empty, and all requests are slower than normal as the site needs to warms up.

To prevent the idle shutdown, you can set the Always On flag in the App Service Configuration blade.

The Always On App Service Flag

Use a Local Cache

By default, the file system for your App Service is mounted from Azure Storage. The good news is your file system is durable, highly available, and accessible from multiple App Service instances. The sad news is your application makes a network call every time the app touches the file system.

Some applications require the Azure Storage solution. These are the applications that write to the file system, perhaps when a user uploads a file, and they expect the file system changes to be durable, permanent, and immediately visible across all running instances of the application. Other applications might benefit from having a faster, local, read-only copy of the website content. If this sounds like your application, or you want to run a test, then create a new App Setting for the app with a key of WEBSITE_LOCAL_CACHE_OPTION and a value of Always. You'll then have a d:\home folder pointing to a local cache on the machine and populated with a copy of your site content.

Using a Local Cache

Although I say the cache is read-only, the truth is you can write into the local cache folder. However, you'll lose any changes you make after an app restart. For more information on the tradeoffs involved and how the local cache works with log files, see the Azure App Service Local Cache overview.

Keep Your Customers Close, and Your Resources Even Closer

All the performance improvements we've looked at so far only require configuration changes. The next set of improvements require some additional infrastructure planning or restructuring, and in some cases changes to the application itself. The common theme in the next set of tips is to reduce the distance bits need to travel over the network. The speed of light is finite, so the further a bit has to travel, the longer the bit needs to reach a destination.

Co-Locate Your App Service and Your Database

In Azure you assign most resources you create to a specific region. For example, when I create an App Service, I can place the service close to me in the East US region, or, if I'm on an extended visit to Europe, I can select the North Europe region. If you create multiple resources that work together closely, you'll want to place the resources together in the same region. In the past I've seen performance suffer when someone at the company accidentally places an App Service in one region and an associated Azure SQL instance in a different region. Every database query from the App Service becomes a trip across the continent, or around the world.

How do you check your existing subscriptions to make sure your resources are properly co-located? Assuming you don't want to click through the portal to check manually, you can write a custom script or program, or use Azure Policy. Azure Policy has a built-in rule to check every resource to ensure the resource location matches the location of the resource's parent resource group. All you need to do with this rule in place is make sure your associated resources are all in the same resource group. The policy definition for this audit rule looks like the following.

{
  "if": {
    "field": "location",
    "notIn": [
      "[resourcegroup().location]",
      "global"
    ]
  },
  "then": {
    "effect": "audit"
  }
}

Keep Your App Service Close to Your Customer

If most of your customer traffic originates from a specific area of the world, it makes sense to place your resources in the Azure region closest to your customers. Of course, many of us have customers fairly distributed around the world. In this case, you might consider geo-replicating your resources across multiple Azure regions to stay close to everyone. For App Services, this means creating multiple App Service plans inside of multiple Azure data centers around the world. Then, you'll typically use a technology like Azure Traffic Manager to direct customer traffic to the closest App Service instance.

Traffic Manager is a DNS-based load balancer. So, when a customer's web browser asks for the IP address associated with your application's domain, Traffic Manager can use rules you provide and other heuristics to select the IP address of a specific App Service. Traffic Manager can select the App Service with the lowest latency for a given customer request, or you can also configure Traffic Manager to enforce geo-fencing where the load balancer sends all customers living in a specific province or country to the App Service you select. You can see the routing methods built into Traffic Manager in the Create Traffic Manager profile blade below.

Setting up a Traffic Manager Profile

There are tradeoffs and complications introduced by Traffic Manager. It is easy to replicate stateless web applications and web services across data centers around the world, but you'll need to spend some time planning a data access strategy. Keeping one database as the only source of truth is the easiest data access approach. But, if your App Service in Australia is reading data from a database in the U.K., you might be losing the performance benefits of geo-replicating the App Service. Another option is to replicate your data, too, but much depends on your business requirements for consistency. Data replication is typically asynchronous and delayed, and your business might not be able to live with the implications of eventual consistency.

Keep Your Content Close to the Customer

Azure's content delivery network allows you to take static content from Azure Storage, or from inside your App Service, and distribute the content to edge servers around the world. Again, the idea is to reduce the distance information needs to travel, and therefore reduce the latency in network requests. Static files like script files, images, CSS files, and videos, and are all good candidates for caching on the CDN edge servers. A CDN can have other benefits, too. Since your App Service doesn't need to spend time or bandwidth serving files cached on a CDN, it has more resources available to produce your dynamic content.

When setting up a CDN profile in Azure, you can select a pricing plan with the features you need from a set of providers that includes Microsoft, Verizon, and Akamai.

Setting up a CDN Profile

Keep Your Apps Together

Today's architecture fashion is to decompose systems into a set of microservices. These microservices need to communicate with each other to process customer requests. Just like keeping your application and database close together can benefit performance, keeping your microservices close to each other can benefit performance, too.

With App Services, remember that multiple services can live on the same App Service Plan. Think of the plan like a virtual machine dedicated to the role of a web server. You can place as many applications on the web server as you like, and keeping services together can reduce network latency. However, keep in mind that having too many services on the same machine can stretch resources thin. It will take some experimentation and testing to figure out the best distribution of services, the ideal size of the App Service Plans, and the number of instances you need to handle all your customer requests.

Summary

We've looked at several strategies we can use to improve the performance of web applications and web APIs we've deployed to Azure App Services. Just remember that your first step before trying one of these strategies should be to measure your application performance and obtain a good baseline number. Not every strategy in this article will benefit every application. Starting with baseline performance numbers will allow you to compare strategies and see which ones are the most effective for your application.

Build a Countries List with Telerik UI for WinForms DomainUpDown

$
0
0

In this blog post, you will learn more about the DomainUpDown control in Telerik UI for WinForms and how to use it to build a selection list for countries.

RadDomainUpDown in Telerik UI for WinForms is a combination of a text-box and a pair of moving up and down buttons to navigate through a limited selection of options. This control may save you some screen space since it occupies the space needed for a standard text-box. However, in addition, it allows the end user to select one of a variety of several items.

A common use-case is to build an input form for filling personal information. One of the required fields is the nationality. RadDomainUpDown is suitable for introducing the countries options if you don’t want to allocate  a lot of space on the form.

DomainUpDown_Animated

Adding Countries to the DomainUpDown Control

You can add the country items either at design time or at run time.

Adding Items at Design Time

The RadListDataItem Collection Editor allows you to do that. You can access it through the Smart tag >> Edit Items option:

DUD_01

Adding Items at Run Time

For each country option, add a RadListDataItem to the Items collection that RadDomainUpDown offers:

RadListDataItem item1 = newRadListDataItem("Bulgaria");
RadListDataItem item2 = newRadListDataItem("France");
RadListDataItem item3 = newRadListDataItem("Italy");
this.radDomainUpDown1.Items.AddRange(newList<RadListDataItem>()
 
{
    item1,
    item2,
    item3
});

Adding Flags to the Countries

Open the project’s Resources and add the flags for the countries that you have added:

DUD_02

DUD_03

Adding Country Flags at Design Time

Open the RadListDataItem Collection Editor again and assign an image to each RadListDataItem:

DUD_04

Adding Country Flags at Run Time

Set the Image property for each RadListDataItem:

item1.Image = Properties.Resources.BUL;
item2.Image = Properties.Resources.FR;
item3.Image = Properties.Resources.ITA;

The last thing to do is to set the ReadOnly property to true. Thus, the item’s image will be shown next to the text after making a selection:

DUD_05

Wrapping Items

Set the Wrap property to true if you need the selected item to revert to the first item after reaching the last item and vice versa.

DomainUpDownWrap 

Data Validating

The SelectedIndexChanging event allows you to control whether the newly selected item is valid according to the other fields’ input, e.g. selected town. If the selection is not valid simply set the Cancel argument to true:

privatevoidradDomainUpDown1_SelectedIndexChanging(objectsender,
    Telerik.WinControls.UI.Data.PositionChangingCancelEventArgs e)
{
    if(e.Position>-1 && this.radDomainUpDown1.Items[e.Position].Text=="Italy")
    {
        e.Cancel = true;
    }
}

Try It Out and Share Your Feedback

You can learn more about the Telerik UI for WinForms suite via the product page. It comes with a 30-day free trial, giving you some time to explore the toolkit and consider using it for your current or upcoming WinForms development.

Start My Trial

We would love to hear what you think, so should you have any questions and/or comments, please share them to our Feedback Portal.

Header and Footer in Telerik UI for Xamarin ListView

$
0
0

The Telerik UI for Xamarin ListView control now features Header and Footer support, giving you new opportunities to customize the experience for your users.

With Telerik UI for Xamarin, you can now add custom content to the top and bottom of your list view using the HeaderTemplate and the FooterTemplate properties of the ListView. You can use them in your mobile app to display descriptive information about the content (list view items). In this blog post I will show you how both templates can be added to the RadListView control

ListView Header and Footer

HeaderTemplate

The HeaderTemplate can be used for adding custom content to the top of the items container. It could be used in different cases, for example to add text which gives an overview for the list view content. The snippet below shows how to add the HeaderTemplate:

<telerikDataControls:RadListView.HeaderTemplate>
    <DataTemplate>
        <LabelText="All mail"/>
    </DataTemplate>
</telerikDataControls:RadListView.HeaderTemplate>

FooterTemplate

The RadListView FooterTemplate is displayed at the bottom of the list view items. Here's a sample use-case scenario: say the items in the list view are messages and you want to execute some operation to all/some of them - in the footer template you can add a button that, when clicked, deletes all/the selected messages, or marks them "as read." Here is how a sample Footer Template could be defined:

<telerikDataControls:RadListView.FooterTemplate>
    <DataTemplate>
        <ButtonText="Delete all"Clicked="Button_Clicked"/>
    </DataTemplate>
</telerikDataControls:RadListView.FooterTemplate>

Please note that both templates are scrollable along the items in the ListView. For more details check our help article here.

Using Header and Footer in the Xamarin ListView

Let’s create a sample app using the HeaderTemplate and the FooterTemplate. For the demo we are going to use the RadDockLayout control. RadDockLayout provides a mechanism for child elements to be docked to the left, right, top or the bottom edge of the screen or to occupy the center area of the layout. You can easily arrange the views in order to achieve a fully featured layout of a page.

Let's create a view model and a business object that will be the source of the list view: 

publicclassViewModel
{
    publicViewModel()
    {
        this.Source = newObservableCollection<News>()
        {
            newNews("As a Front-End Developer, you will be responsible for the look, feel and navigation of complex enterprise ecommerce solutions."),
            newNews("We’re looking for a UX Architect for our UX/UI team who tells cohesive, well-thought and user tested stories through mind maps, user flows and ultimately, prototypes. "),
            newNews("Define consistent UI style guides and page layouts. "),
            newNews("You will be speaking to customers, using data to inform your designs, and, since we believe in design as a team effort, have an open work process with regular design critiques and peer feedback.")
        };
    }
    publicObservableCollection<News> Source { get; set; }
}
 
publicclassNews
{
    publicNews(stringdescription)
    {
        this.Description = description;
    }
 
    publicstringDescription { get; set; }
}

Finally, lets declare the RadDockLayout and dock the RadListView control to occupy the remaining space of the screen:

<ScrollViewBackgroundColor="White">
    <telerikCommon:RadDockLayout>
        <GridtelerikCommon:RadDockLayout.Dock="Top"
            BackgroundColor="#009688"
            HeightRequest="50">
            <LabelText="Job Descriptions"VerticalTextAlignment="Center"/>
        </Grid>
        <GridtelerikCommon:RadDockLayout.Dock="Bottom"
            HeightRequest="50"
            BackgroundColor="#659BFC">
            <LabelText="Navigation"VerticalTextAlignment="Center"/>
        </Grid>
        <Grid>
            <telerikDataControls:RadListViewItemsSource="{Binding Source}">
                <telerikDataControls:RadListView.BindingContext>
                    <local:ViewModel/>
                </telerikDataControls:RadListView.BindingContext>
                <telerikDataControls:RadListView.HeaderTemplate>
                    <DataTemplate>
                            <telerikPrimitives:RadBorderPadding="5">
                                <StackLayoutOrientation="Horizontal"BackgroundColor="#F7F7F7">
                                    <telerikPrimitives:RadBorderCornerRadius="30"
                                                        HorizontalOptions="Start"
                                                        WidthRequest="60"
                                                        HeightRequest="60"
                                                        Margin="10">
                                        <ImageSource="Avatar.png"Aspect="AspectFill"/>
                                    </telerikPrimitives:RadBorder>
                                    <StackLayoutOrientation="Vertical"Spacing="0"VerticalOptions="Center"HorizontalOptions="StartAndExpand">
                                        <LabelText="Jane"FontAttributes="Bold"TextColor="Black"Margin="0"/>
                                        <LabelText="@jane"TextColor="#919191"Margin="0"/>
                                    </StackLayout>
                                    <telerikInput:RadButtonText="Add news"
                                                    BackgroundColor="Transparent" 
                                                    BorderColor="#007AFF"
                                                    BorderRadius="30"
                                                    BorderWidth="2"
                                                    Margin="5"
                                                    WidthRequest="100"
                                                    HeightRequest="40"
                                                    Padding="12,3,12,3"
                                                    HorizontalOptions="End"
                                                    VerticalOptions="Center"
                                                    TextColor="#007AFF"/>
                                </StackLayout>
                        </telerikPrimitives:RadBorder>
                    </DataTemplate>
                </telerikDataControls:RadListView.HeaderTemplate>
                <telerikDataControls:RadListView.FooterTemplate>
                    <DataTemplate>
                        <telerikPrimitives:RadBorderPadding="5"BackgroundColor="#F7F7F7">
                            <telerikInput:RadButtonText="Share news"
                                            TextColor="White"
                                            WidthRequest="200"
                                            HeightRequest="40"
                                            VerticalOptions="Center"
                                            HorizontalOptions="Center"
                                            CornerRadius="25"
                                            Margin="0, 5, 0, 5"
                                            Padding="15,5,15,5"
                                            BackgroundColor="#007AFF"/>
                        </telerikPrimitives:RadBorder>
                    </DataTemplate>
                </telerikDataControls:RadListView.FooterTemplate>
                <telerikDataControls:RadListView.ItemTemplate>
                    <DataTemplate>
                        <telerikListView:ListViewTemplateCell>
                            <telerikListView:ListViewTemplateCell.View>
                                <StackLayoutOrientation="Vertical"Margin="10, 10, 10, 10"BackgroundColor="White">
                                    <LabelText="{Binding Description}"FontSize="15"Margin="3"TextColor="Black"/>
                                </StackLayout>
                            </telerikListView:ListViewTemplateCell.View>
                        </telerikListView:ListViewTemplateCell>
                    </DataTemplate>
                </telerikDataControls:RadListView.ItemTemplate>
            </telerikDataControls:RadListView>
        </Grid>
    </telerikCommon:RadDockLayout>
</ScrollView>

The image below shows the final result:

Demo App

That's all, now you have your list view with header and footer. 

Tell Us What You Think

Have we caught your interest with the RadListView new features and the RadDockLayout control? We would love to hear what you think about them. If you have any ideas for features to add, do not hesitate to share this information with us on our Telerik UI for Xamarin Feedback portal.

Don’t forget to check out the various demos of the controls in our SDK Sample Browser and the Telerik UI for Xamarin Demos application.

If you have not yet tried the Telerik UI for Xamarin suite, take it out for a spin with a 30-day free trial, offering all the functionalities and controls at your disposal at zero cost.

Start My Trial

Happy coding with our controls!

The Uno Platform And WebAssembly

$
0
0

On this episode of Eat Sleep Code, we talk about using Uno to create cross platform .NET apps, and what WebAssembly means for deploying .NET to the web.

Join us as we talk with Jérôme Laban, Uno Platform CTO, about the prospects of using Uno to create cross platform .NET applications. Jérôme also discusses the use of WebAssembly by Uno and what WebAssembly means for deploying .NET to the web.

You can listen to the entire show and catch past episodes on SoundCloud. Or just click below.

Jérôme Laban

jerome.laban

Jerome Laban has been programming since 1998, mainly involved in .NET and C# development as teacher, trainer, consultant in France. He is the CTO of Uno Platform in Montreal, a framework aiming at improving the development cycle of cross-platform apps using Windows, iOS, Android and WebAssembly using Mono and Xamarin. Uno Platform

Show Notes

Viewing all 1954 articles
Browse latest View live