This is the best way that I've discovered to implement INotifyPropertyChanged in a XAML based MVVM app without downloading any extra supporting code.It relies on the ref keyword to allow a method in the base class to modify the property that you wish to raise a property changed event for. The code is fairly concise and it doesn't add any unseen overhead.
In your view model all you need to do is:
public class MyViewModel : ObservableViewModelBase
public string Name
get => _name;
set => SetProperty(ref _name, value);
The Hitchhiker’s Guide to the Galaxy is perhaps the most remarkable, certainly the most successful book ever to come out of the great publishing corporations of Ursa Minor. It is an indispensable companion to any weary traveller roaming the celestial highways. While providing a huge amount of vital galactic information, it is well known to have a hugely popular word search section to help pass the hours while waiting for the next passing spaceship.Till now this section has never been published or even seen on the mostly harmless planet Earth. So, I was very excited to find a battered and …
Should we write code SOLID? I’ve always liked a bit of single responsibility principal and dependency injection, but don’t often find myself using interface segregation.
Dan North argues that the SOLID Principals are not the be all and end all of good software. On a recent .NET Rocks 1745 he explains what’s wrong with SOLID and puts forward his own set of CUPID Properties. Properties are less strict than principals, but if you write code that has more of these properties then it will be better.
Dan North seems to have plans to write a series of detailed blog posts about the CUPID properties, …
Previously when generating links inside any non view code I'd always try and get hold of an instance of IUrlHelper, but I've found a simpler way that has been available since .NET Core 2.2.
LinkGenerator can be injected into a tag helper or any class. It has all the useful methods of IUrlHelper, with fewer dependencies. It only asks for HttpContext if it absolutely needs it, which in many cases it does not.
Inject it into your class like so:
private readonly LinkGenerator _linkGenerator;
public NogginTagHelper(LinkGenerator linkGenerator)
_linkGenerator = linkGenerator;
Using the …
I've discovered a better way of doing this. Check out my new post on using LinkGenerator instead.
If you're writing a tag helper and would like to generate links using IUrlHelper then you can not inject this directly. You need to inject an IUrlHelperFactory and then there are a few hoops that you need to jump through.
This is how to set up the UrlHelper inside you tag helper constructor:
private readonly IUrlHelper _urlHelper;
public NogginTagHelper(IUrlHelperFactory urlHelperFactory, IActionContextAccessor contextAccessor)
_urlHelper = urlHelperFactory.GetUrlHelper(contextAccessor. …
I miss going to user groups, but with all the videos online now it is does mean I can get to more of the slightly further away user groups like Dot Net North. Even if I don't get to talk to anyone there.
I first saw Docker being used by a developer in my co-working space for his Dating Site Whitelabel platform. The platform's userbase was growing and he was experimenting with different infrastructures to help support that growth. Docker enabled him to set up test environments that would be identical to the final production environment, to set them up quickly and repeatedly. He found this …
It's now possible to make your cookies more secure and be explicit about what sites you want to be able to read them.So, I've been making most of the cookies I use have a same site policy of strict. My understanding was that this would mean that only my site would be able to read them, which is exactly what I wanted. Except, they were even stricter than I expected and caused an unexpected side effect that made our site unusable.
After making some changes to our login procedure the site got stuck in an endless redirect loop. This is what was happening:
The user logs in successfully using a …
We use App Insights at work to collect all our logged messages. App Insights comes with a very powerful query language confusingly named Kusto Query Language (KQL) that lets you get whatever you want from the logs. However App Insights shows you surprisingly little out of the box. So without some configuration you may not be getting as much value from your logs as you could.
The thing I really wanted to see was the most common log messages ordered by how often they had happened in the specified time. This is the KQL query for that:
// Setup mapping array to make severity level use friendly …
We had a great talk at Leeds Sharp this month. Would love to have seen this in person, but remote Leeds Sharp continues with more great talks.
Clifford Agius showed us what you can acheive with a 3D printer by talking us through his long running project to make a better bionic hand for Hayden, the son of a close friend. As bionic hands are so expensive (currently around £45,000) and children grow out of the quickly, you can't get one from the NHS till you're fully grown. 3D printing and open source plans show a lot of exciting potential to make things better, cheaper and share them with …
This website has been down for a few weeks since my old web host lost my virtual machine in a RAID disaster. If my business depended on this website I would have spent more time and money on my backup strategy. And although this is not a business critical site, it is still one close to my heart and the pain and time taken to get this site back up has been more than I anticipated.
This site was hosted on a cheap VM with UK Webhosting. I was not paying for the optional extra of backups. But I was regularly backing up the database and saving it on the server. I made the assumption (NEVER MAKE …