Category Archives: .NET

Microsoft .NET issues and solutions

DataGridComboBoxColumn.ItemsSource binding issue

The code below doesn’t work as one would expect, i.e. to allow selecting one value for each item in the DataGrid using ComboBoxes in a secondary column, even if if there is an AvailableValues property in the Window container class … Continue reading

Posted in WPF | Tagged , , , | Leave a comment

XAML element properties and cut-paste refactoring

As you know, to set properties for WPF objects in XAML, one uses either attributes or elements, like the Text and LayoutTransform properties of the TextBox element below, respectively: <Border> <TextBlock Text=”Hello!”> <TextBlock.LayoutTransform> <ScaleTransform ScaleY=”2″/> </TextBlock.LayoutTransform> </TextBlock> </Border> Using elements is required when … Continue reading

Posted in WPF | Tagged , , , , , , | Leave a comment

Bloody space in a form input name

Suppose that you have to HTTP-post a form with some pre-computed hash field to a service. You prepare the form as HTML or as an HTTP client call, with a hidden input field or a request body parameter that is … Continue reading

Posted in HTML5, WebAPI | Tagged , , , , , , | Leave a comment

Auto-disposing? Empty using syntax?

What do you think? Should this code auto-dispose the X object instance created but not used? If you test it, you’ll see it does not: public class X : IDisposable { … } static void Main(string[] args) {     … Continue reading

Posted in C# | Tagged , , , | Leave a comment

Mocking Entity Framework to unit test your data services

It’s not easy to write unit tests for services that use DbContext and DbSet<T> classes from Entity Framework (or Entity Framework Core), and there are complex solutions to approach this, like separating the data access layer completely, as I propose in my UnitOfWork-EntityFramework implementation. … Continue reading

Posted in Architecture, C# | Tagged , , , , , , | Leave a comment

Enabling Entity Framework Core 1.1 tools

After I created an ASP .NET Core 1.1 project (Console app) with Visual Studio 2017 to develop a new WebAPI, I wanted to add support for EntityFrameworkCore. Everything was OK, except for the Tools.DotNet package, which I couldn’t add with … Continue reading

Posted in .NET, ASP .NET, Miscellaneous, WebAPI | Tagged , , | Leave a comment

FileUpload in UpdatePanel

Want to include a FileUpload in UploadPanel using Ajax-enabled ASP .NET WebForms? You need to do two things: Set encoding type to the form element to multi-part: <form … enctype=”multipart/form-data”> Add a non-async postback trigger on the UpdatePanel for the button that … Continue reading

Posted in ASP .NET | Tagged , , , , | Leave a comment