Recent Discussions
Convert the standard Blazor navigation menu to a collapsible icon menu
While I admittedly love Blazor I’ve always changed the out-of-the-box navigation menu that comes with it. It’s the first manoeuvre I pull when spinning up a new Blazor app, stripping out the purple gradient and getting it in, what I consider, a “blank slate state”. The other change I’ve wanted to make to the out-the-box look is one of those deluxe collapsible menus that leave just the icons showing. Anyone that’s used Azure DevOps will know what I’m talking about. I’ve included a picture to show DevOps example of what I’d like to see in my Blazor app. It gives a load of extra screen real estate which is always a priority for me in business applications particularly with complex or intensive workflows. Plus it gives the user the option to remove the text prompts once they are familiar with the system which is supported with carefully selected icon choices. As with most tasks that I assume will be an obvious solution I hit my search engine of choice and looked to avoid reinventing the wheel. However I found no source of pre-written changes to achieve this and was directed to fairly expensive third party controls to solve this one for me, which, being tight fisted, pushed me to do it for myself. Here I hope you save you the trouble of paying a pretty penny or having to wrestle the CSS into submission and provide a guide for producing a nice collapsible icon navigation menu by altering the existing out of the box menu in Blazor. In the following example I have left all the standard styling as is with the menu and just done the changes required to make the collapsible menu. The three files that require changes are MainLayout.razor, NavMenu.razor and NavMenu.razor.css. The code changes are shown below: Firstly the NavMenu.razor requires a bool value (IconMenuActive) to indicate whether the icon menu is showing or not, then wrap the text of the each NavItem in an if statement dependent on this bool. Then a method for toggling this bool and EventCalBack to send a bool to the MainLayout.razor for shrinking the width of the sidebar. Lastly there needs to be the control for switching menu views (I used the standard io icon arrows). NavMenu.razor <div class="top-row ps-3 navbar navbar-dark"> <div class="container-fluid"> <span class="oi oi-monitor" style="color:white;" aria-hidden="true"></span> @if (!@IconMenuActive) { <a class="navbar-brand" href="">The Menu Title Here</a> } <button title="Navigation menu" class="navbar-toggler" @onclick="ToggleNavMenu"> <span class="navbar-toggler-icon"></span> </button> </div> </div> <div class="@NavMenuCssClass" @onclick="ToggleNavMenu"> <nav class="flex-column"> <div class="nav-item px-3"> <NavLink class="nav-link" href="" Match="NavLinkMatch.All"> <span class="oi oi-home" aria-hidden="true"></span> @if (!@IconMenuActive) { <label>Home</label> } </NavLink> </div> <div class="nav-item px-3"> <NavLink class="nav-link" href="c/https://techcommunity.microsoft.com/category/ounter"> <span class="oi oi-plus" aria-hidden="true"></span> @if (!@IconMenuActive) { <label>Counter</label> } </NavLink> </div> <div class="nav-item px-3"> <NavLink class="nav-link" href="f/https://techcommunity.microsoft.com/category/etchdata"> <span class="oi oi-list-rich" aria-hidden="true"></span> @if (!@IconMenuActive) { <label>Fetch data</label> } </NavLink> </div> </nav> </div> <div class="bottom-row"> <div class="icon-menu-arrow"> @if (!@IconMenuActive) { <span class="oi oi-arrow-left" style="color: white;" @onclick="ToggleIconMenu"></span> } else { <span class="oi oi-arrow-right" style="color: white;" @onclick="ToggleIconMenu"></span> } </div> </div> @code { //bool to send to MainLayout for shrinking sidebar and showing/hide menu text private bool IconMenuActive { get; set; } = false; //EventCallback for sending bool to MainLayout [Parameter] public EventCallback<bool> ShowIconMenu { get; set; } private bool collapseNavMenu = true; private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null; private void ToggleNavMenu() { collapseNavMenu = !collapseNavMenu; } //Method to toggle IconMenuActive bool and send bool via EventCallback private async Task ToggleIconMenu() { IconMenuActive = !IconMenuActive; await ShowIconMenu.InvokeAsync(IconMenuActive); } } Next I add in a bit of CSS in to NavMenu.razor.css to put the arrow for toggling the menu at the bottom of the sidebar and a media query to make sure it doesn't show up in mobile view. The CSS classes added are .bottom-row and .icon-menu-arrow. NavMenu.razor.css .navbar-toggler { background-color: rgba(255, 255, 255, 0.1); } .top-row { height: 3.5rem; background-color: rgba(0,0,0,0.4); } .bottom-row { position: absolute; bottom: 0; padding-bottom: 10px; text-align: right; width: 100%; padding-right: 28px; } .icon-menu-arrow { text-align: right; } .navbar-brand { font-size: 1.1rem; } .oi { width: 2rem; font-size: 1.1rem; vertical-align: text-top; top: -2px; } .nav-item { font-size: 0.9rem; padding-bottom: 0.5rem; } .nav-item:first-of-type { padding-top: 1rem; } .nav-item:last-of-type { padding-bottom: 1rem; } .nav-item ::deep a { color: #d7d7d7; border-radius: 4px; height: 3rem; display: flex; align-items: center; line-height: 3rem; } .nav-item ::deep a.active { background-color: rgba(255,255,255,0.25); color: white; } .nav-item ::deep a:hover { background-color: rgba(255,255,255,0.1); color: white; } @media (min-width: 641px) { .navbar-toggler { display: none; } .collapse { /* Never collapse the sidebar for wide screens */ display: block; } } @media (max-width: 640px) { .bottom-row { display: block; } } Finally I add in the handler for the EventCallback to MainLayout.razor and a method to alter the width of the sidebar. MainLayout.razor @inherits LayoutComponentBase <div class="page"> <div class="sidebar" style="@IconMenuCssClass"> <NavMenu ShowIconMenu="ToggleIconMenu"/> </div> <main> <div class="top-row px-4"> <a href="/https://docs.microsoft.com/aspnet/" target="_blank">About</a> </div> <article class="content px-4"> @Body </article> </main> </div> @code{ private bool _iconMenuActive { get; set; } private string? IconMenuCssClass => _iconMenuActive ? "width: 80px;" : null; protected void ToggleIconMenu(bool iconMenuActive) { _iconMenuActive = iconMenuActive; } } The final product of these little changes are shown in the pictures below: I'd love to hear if anyone has tackled this in a different way to me and if they've got any ideas on making it cleaner. Have yourselves a wonderful day, Gav70KViews10likes14CommentsWhat's the future of RDLC ("client-side SSRS", aka "ReportViewer")?
This is the information I could gather so far: Getting an RDLC renderer for .NET 5+ is currently the fourth highest-voted feature on the SQL Server user wishlist. Unfortunately, there are currently no plans to do that (see the comments here). There are some enthusiast ports/recompilations floating around on github and nuget, but they are not official. The SQL Server Reporting Services Team Blog is dead, the last entry is from 2018. There's a third-party company providing an RDLC renderer, but Microsoft acquired them in 2018. Nothing has been heard since. There is currently no ReportViewer designer for Visual Studio 2022. Getting one is currently the fourth highest-voted feature on the Visual Studio 2022 wishlist. From a business perspective, I can totally understand that Microsoft is not giving this highly-loved feature the resources it needs. After all, they are basically giving away a great reporting engine for free, undermining their own SQL Server and Power BI sales. And they are not even hiding the fact that they'd rather have people purchase Power BI subscriptions, which is perfectly fine. They are a company, not a charity. Unfortunately, adding a dependency to a third-party cloud service is a no-go for many software development scenarios. Thus, I would like to start a discussion on the following points: It seems to me that MS no longer wants people to use their RLDC reporting engine in new projects. Is this observation correct? If you have a large repository of RDLC reports in your project, what are your migration plans? Are there drop-in replacements from third parties? Would Microsoft consider open-sourcing the RLDC engine, so that the community can "keep the product alive" for legacy scenarios and prevent this from being a blocker in .NET 5+ migrations? Best regards Heinzi12KViews8likes0CommentsHow many of you want Microsoft to support office/excel web add-ins using Blazor WASM?
Hello everyone, I would like the Blazor team to support creating excel/office web add-in using Blazor WASM. They only support REACT at the moment. I think supporting Blazor can make a big impact with .net developers and has a huge potential.671Views8likes0CommentsReview GitHub Pull Requests in Visual Studio 2022
Used the GitHub Extension for Visual Studio 2019 to review Pull Requests. Now it looks like that extension is included in VS 2022. However, when going to 'Git/GitHub/View Pull Requests' it redirects me to the browser. Do you know how you can review pull requests in VS 2022 ?9.7KViews7likes5Comments.NET Conf 2021 Recap – Videos, Slides, Demos, and More
.NET Conf 2021 was the largest .NET Conf ever with over 80 sessions from speakers around the globe! We want to give a huge THANK YOU to all who tuned in live, asked questions in our Twitter feed, and participated in our fun and games. The learning continues with community-run events happening thru the end of January so make sure to check those out. Also, watch the session replays and keep an eye on our conference GitHub repo where we are collecting all the slides and demos from our presenters. If you participated in .NET Conf 2021, please give us your feedback about the event so we can improve in 2022. On-Demand Recordings We had a lot of awesome sessions from various teams and community experts that showed us all sorts of cool things we can build with .NET across platforms and devices. You can watch all of the sessions right now on the .NET YouTube or the new Microsoft Docs events hub. What were your favorite sessions? Leave them in the comments below! I have so many favorites, but I loved the Productivity talk around Roslyn and AI with Mika: I also recommend the C# 10 session with Mads and Dustin. Explore Slides & Demo Code All of our amazing speakers have been uploading their PowerPoint slide decks, source code, and more on the official .NET Conf 2021 GitHub page. Be sure to head over there to download all of the material from the event and don’t forget you can still grab digital swag as well! .NET Podcasts App We are happy to announce the release of .NET Podcast app, a sample application showcasing .NET 6, ASP.NET Core, Blazor, .NET MAUI, Azure Container Apps, and more from the .NET Conf 2021 keynote! Grab the source code on GitHub and start exploring locally on your machine, or fork the repo and deploy to Azure with GitHub actions in a few easy steps. Launch After Party Q&A on December 16th On December 16, 2021 .NET Conf and Visual Studio 2022 launch event speakers and experts will be LIVE to answer all of your questions. Learn more about the recent launch of Visual Studio 2022 and .NET 6, including tips and tricks, new features with the latest releases, and connect with others in your community. Register for the event today! Local .NET Conf Events The learning continues with community-run events happening thru the end of January, so be sure to find a local event and sign up today!. Thanks again to everyone that made .NET Conf 2021 possible and we can’t wait for even more .NET Conf events in 2022!7.2KViews6likes3CommentsUnique Device Identifier in MAUI
I am looking for a way to get a device identifier in NET MAUI that is cross platform compliant between Android/iOS/Windows. I originally had this code working in Xamarin Forms with the following: Android Context context = Application.Context; id = Settings.Secure.GetString(context.ContentResolver, Settings.Secure.AndroidId); iOS UIDevice.CurrentDevice.IdentifierForVendor.AsString().Replace("-", ""); Is there anything currently or planned in the future for use in NET MAUI. Thanks In Advance, Stuart Ferguson11KViews3likes1CommentSystem.Text.Json Source Generators Makes Serialization 40% Faster in ASP.NET!
In this video I looked at how to use Source Generators with System.Text.Json to improve serialization and deserialization performance by up to 40%. We then looked at how we can use this in an ASP.NET application. https://www.youtube.com/watch?v=sRCAwmF2arY976Views3likes1CommentUpgrading ASP.NET Core to .NET 6 & C# 10
Check out my series of videos where I try upgrading an ASP.NET Core project template to .NET 6 & C# 10. We looked at the following new features: - Source generated Log messages. - Hot reload. - New launchSettings.json settings. - Validating configuration on startup. - New Strongly typed HTTP header properties. https://www.youtube.com/watch?v=T6iP7QPWmPI In part two, I continue upgrading an ASP.NET Core project template to .NET 6 & C# 10. In this show we looked at: - Open Telemetry in ASP.NET Core. - New hidden features in ASP.NET Core hosting. - New DI method CreateAsyncScope. - New Configuration method GetRequiredSection. - New ArgumentNullException.ThrowIfNull API. - Record classes. https://www.youtube.com/watch?v=mcC9jFLoOlM1.1KViews3likes0CommentsServer-side Blazor state management
One of the more interesting things about server-side Blazor is that, unlike all previous UI frameworks, it maintains all per-user state (including the user's identity) in a dependency injection scope. Windows Forms, WPF, and UWP use the current thread. ASP.NET normally uses HttpContext. Blazor WebAssembly is similar to WinForms/WPF - a single process space for the user and app. But server-side Blazor is stateful on the server, so it can't rely on HttpContext, or any specific thread. So the way they implemented management of things like the current user's principal/identity is via DI scope. Each server-side Blazor app is hosted in its own DI scope, and so a service added as a scoped service is exactly what is necessary to maintain any per-user information. The downside to this, is that if you (like me) have any static methods that, for example, check the user's permissions based on user identity - well, that's impossible. It is impossible because the user's identity isn't "ambient" like in all other UI frameworks. The user's identity is only available in an _instance_ of a type, and only if a service that has the user identity was injected into your instance! As a result, I've spent many, many hours over the past couple weeks rewriting the #cslanet framework so it gets the user identity via DI, and then passes the identity around to all objects that need it (which is a lot - CSLA is primarily a rules engine, so the user identity is necessary all over the place). It turns out that DI, like async/await, is like a virus. Once you start using it a little, pretty soon you find that you've had to rewrite nearly all your code to rely on the concept.2.1KViews3likes1Comment.NET 8.0.2 Update Causes ASP.NET Core MVC 'Index View Not Found' Error
Hello everyone, I recently updated to .NET 8.0.2 and encountered an issue with my ASP.NET Core MVC application. After the update, the application began throwing an error related to the 'Index' view not being found. This issue was not present prior to the update. An unhandled exception has occurred while executing the request. System.InvalidOperationException: The view 'Index' was not found. The following locations were searched: /Views/Home/Index.cshtml /Views/Shared/Index.cshtml This error is generated by the Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware and specifically indicates that the MVC framework is unable to locate the 'Index.cshtml' file in both the 'Home' and 'Shared' directories, where it traditionally searches for views. I've verified the existence of the 'Index.cshtml' file in the correct location and ensured that the routing configurations are set up correctly. This setup was working seamlessly before the update to .NET 8.0.2. Update: I was able to resolve this issue by uninstalling the .NET 8.0.2 updates. After reverting to the previous version, the application started working as expected without any errors. It appears that the .NET 8.0.2 update may have introduced a change or incompatibility affecting the way ASP.NET Core MVC applications locate views.32KViews2likes6CommentsWPF: Project doesn't find its own Classes ("tag not found in namespace")
Hi there, I've got a problem that's driving me crazy: c# WPF Custom Controls Project (NET 7), Base Namespace "UserControls". All the controls, styles and Converters existing in the project are in that namespace (I tripple checked, it's the only namespace used). All the controls and Converters are public classes. In the project, there is a Class named "EqualityToBooleanConverter.cs" Additionally, there is a Style file called Button.xaml. I need to use the aforementioned converter here, so I am referencing it like this: <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:UserControls;assembly=UserControls"> <local:EqualityToBooleanConverter x:Key="ETBConverter" /> Intellisense does find the Namespace "UserControls", in fact, the namespace declaration AND the ressource declaration was done using intellisense. BUT as soon as I compile the project, the following error pops up: MC3074 - type "EqualityToBooleanConverter" does not exist in "clr-namespace:UserControls;assembly=UserControls" I just don't get it, as I said, all the files are in the same project, and they are - as of now - all using the root namespace "UserControls". Everything is fine until I start compiling. What I have tried so far: removing the "assembly"-part of the namespace-declaration changing the compile target from AnyCPU to x86 and back cleaning the solution creating a new solution, and re-adding all the files to it Also noteworthy: The same problem occurs when I try using one of the Usercontrols in that project WITHIN the project itself (like: creating a Window.xaml, defining the local-namespace, and trying to add the control leads to the same error as soon as I compile). I don't know what else could cause this...does anyone have any idea?3.9KViews2likes5CommentsCan we use Maui.Essentials without Maui UI framework?
Previously Xamarin.Essencials was an independed library that could be used with non-XamarinForms applications. Currently this library was rebranded into Maui.Essentials. Which raises a question, if this library become a part of Maui framework with hard dependency on it, or if it still can be used without this GUI framework. I don't see any references to the Maui framework at the moment except Microsoft.Maui.Graphics. Still, I want to see official confirmation stated somewhere. Use cases: 1. We want to be able to build Avalonia applications and use helpers from Maui.Essentials without referencing whole Maui framework. 2. Same about Uno Platform. It should be possible to use it with Maui.Essentials without Maui framework. 3. I also can imagine applications that are built with "net6-ios/android" targets with native UIs without "Forms" from MAUI. These applications will benefit from Maui.Essentials without unnecessary dependency from Maui framework. Thanks, Max Katsydan.3.6KViews2likes2CommentsOneDrive Sync Folder shows processing changes
I have installed the latest semi annual version for OneDrive sync client Some folders in the OneDrive sync folder shows processing changes under status. When the folder is opened, all files in the folder are completely synced. There are no temp files or hidden files in such folders, yet the sync status for this folders show processing changes. I followed guidelines in this KBI <OneDrive is stuck on "Sync pending" (microsoft.com)> to create a new folder, copy all files in the affected folder to the new folder and this resolved the issue; the processing change symbol was replaced by a cloud symbol. However, this issue affects many folders of almost all users of OneDrive for business in my tenant and most of these users are very busy and cannot create new folders and move or copy the contents into a new folder to resolve the issue each time its happens. This issue may look very simple but it is an issue that creates confusion in the minds of users as they doubt if their files have actually synced to their OneDrive accounts in the cloud. Is there an alternate way I can fix this issue in my Tenant for all the users.2.2KViews2likes1CommentManaging web client assets ... and how Snowpack can help
Hello there. I've been wondering what tooling and workflow everyone is using to manage client assets JS/CSS/images etc especially for Blazor and perhaps provide some inspiration in the process (not writing a complete guide, merely a pointer). When trying tools like Libman, Gulp, Webpack, MSBuild it turned out to be either insufficient or too convoluted with lot of complexity and JS code for even basic tasks. My needs were somewhat simple in the head, yet hard to execute: 🟢 Needs to work with CLI/Visual Studio Code ecosystem 🟢 Manage packages with PNPM (faster and more efficient alternative to NPM) 🟢 Self-contained TypeScript source files that would produce fully optimized unbundled importable ESM modules with treeshaking, splitting, minification 🟢 PostCSS with support for nesting, variables, imports. Coupled with TailwindCSS JIT that would automatically generate on-demand minimal CSS styles depending on what is in .razor or even .cshtml & .cs template files. 🟢 All of this would need to happen fast, watcher should rebuild only what is needed every time relevant file is changed and output has to be hot reloaded into running application so work can be done in real-time with current application state. 🟢 Everything must be minimal, automatic, no extraneous declarations and relevant things should sit side-by-side. Only tool that managed to do all this pretty much out of the box is Snowpack lightning-fast frontend build tool, designed for the modern web. Configuration is very simple compared to other tools /* snowpack.config.js */ /** @type {import("snowpack").SnowpackUserConfig } */ module.exports = { mount: { assets: "/", //"assets" folder holds source files for our wwwroot pages: "/pages", //tells snowpack to watch for changes in this folder shared: "/shared", //tells snowpack to watch for changes in this folder "../../node_modules/@fontsource/poppins/files": { //Copy some extra files from node_modules to wwwroot/css/files //Snowpack doesn't resolve font imports "yet" url: "/css/files", static: true, }, }, exclude: ["**/*.cs"], //Don't watch or include C# files in the wwwroot, we'd comment this out if they contained classes for TailwindCSS JIT to pick up plugins: [ "@snowpack/plugin-postcss", //Support for PostCSS ideally in `.pcss` files, needs to be installed separately with PNPM [ "@jadex/snowpack-plugin-exclude", //This plugin makes sure these files are watched for changes, but not included in the final wwwroot { paths: ["**/*.razor", "**/*.pcss"], }, ], ], buildOptions: { clean: process.env.NODE_ENV === "production", //Production build should be cleaned up out: "wwwroot", }, optimize: { minify: true, bundle: false, treeshake: true, splitting: true, target: "es2020", }, }; And that's all you need to do with Snowpack, all your assets will build up nicely in the wwwroot, ready to be consumed by the browser. ------------------------------------------------------ Couple notes how things need to be organized CSS Create folder assets/css and put there your css files you want to act as bundles to be placed in wwwroot. In them import individual .pcss files or globs with postcss-import & postcss-import-ext-glob plugins. /* assets/css/app.css */ @import "tailwindcss/base.css"; @import "tailwindcss/components.css"; @import-glob "./**/_components/**/*.pcss"; @import-glob "../../{Pages,Shared}/**/*.pcss"; @import "../../App.razor.pcss"; @import "tailwindcss/utilities.css"; In your index.html or _Layout.cshtml include as normal <link href="c/https://techcommunity.microsoft.com/category/ss/app.css" rel="stylesheet" /> Snowpack watcher will know when imported pcss is changed and will rebuild the css that imports it. TypeScript Create folder assets/js and put your ts files there /* assets/js/map.ts */ import mapboxgl from "mapbox-gl"; import "mapbox-gl/dist/mapbox-gl.css"; export function initMap(accessToken: string) { mapboxgl.accessToken = accessToken; const map = new mapboxgl.Map({ container: "map", style: "mapbox://styles/mapbox/streets-v11", center: [19.62915, 45.3701] zoom: 15, }); map.addControl(new mapboxgl.FullscreenControl()); map.scrollZoom.disable(); } Don't include in index.html or _Layout.cshtml. Import modules as needed on your pages/layouts. var mapModule = await this.Runtime.InvokeAsync<IJSObjectReference>("import", "./js/map.js"); await this.mapModule.InvokeVoidAsync("initMap", "accessToken"); Other files like Images/Manifests/Favicons Just include in the root of the assets folder or subfolders assets/img etc. It's possible to use plugins to optimize these files too. For example Sharp can be used to optimize, resize images or generate avif/webp variants. Hope someone finds this helpful, should work for MVC and RCL too. Feel free to share your way to tackle the issue or ask questions.1.1KViews2likes0CommentsWelcome to the Machine Learning and AI .NET space!
Hello and welcome to the Machine Learning & AI space! Here are some resources you might find useful: ML.NET Documentation: https://docs.microsoft.com/dotnet/machine-learning Samples: dotnet/machinelearning-samples: Samples for ML.NET, an open source and cross-platform machine learning framework for .NET. (github.com) Repository: dotnet/machinelearning: ML.NET is an open source and cross-platform machine learning framework for .NET. (github.com) Model Builder Repository: dotnet/machinelearning-modelbuilder: Simple UI tool to build custom machine learning models. (github.com) Machine Learning Community Standup (filter for Machine Learning in dropdown): .NET Community Standups | .NET Live TV (microsoft.com) .NET for Apache Spark Documentation: http://docs.microsoft.com/dotnet/spark Repository: dotnet/spark: .NET for Apache® Spark™ makes Apache Spark™ easily accessible to .NET developers. (github.com) Tools .NET Interactive Notebooks: dotnet/interactive: .NET Interactive takes the power of .NET and embeds it into your interactive experiences. Share code, explore data, write, and learn across your apps in ways you couldn't before. (github.com) .NET Interactive Notebooks VS Code extension: .NET Interactive Notebooks - Visual Studio Marketplace Visual Studio Notebook Editor extension: Notebook Editor - Visual Studio Marketplace Numerical & Statistical Libraries Math.NET Numerics: Math.NET Numerics (mathdotnet.com) FSharp.Stats: FSharp.Stats (fslab.org) Plotting / Graphic Libraries Plotly.NET: Plotly.NET Deep Learning Libraries TensorFlow.NET: SciSharp/TensorFlow.NET: .NET Standard bindings for Google's TensorFlow for developing, training and deploying Machine Learning models in C# and F#. (github.com) TensorFlow.Keras: NuGet Gallery | TensorFlow.Keras 0.6.4 TorchSharp: dotnet/TorchSharp: .NET bindings for the Pytorch engine (github.com) DiffSharp: DiffSharp: Differentiable Tensor Programming Made Simple OnnxRuntime: microsoft/onnxruntime: ONNX Runtime: cross-platform, high performance ML inferencing and training accelerator (github.com)2.5KViews2likes0Comments