top of page
starexachidfabsupp

Microsoft toolkit reddit: How to use MTK with Windows 10 and Office 2019



Now that we've outlined all the different components that are available through the CommunityToolkit.Mvvm package, we can look at a practical example of them all coming together to build a single, larger example. In this case, we want to build a very simple and minimalistic Reddit browser for a select number of subreddits.




Microsoft toolkit reddit



Now let's take a look at what we need for viewmodel of the post widget. This will be a much simpler viewmodel, as it really only needs to expose a Post property with the currently selected post, and to receive broadcast messages from the subreddit widget to update the Post property. It can look something like this:


We can assume that platform-specific types implementing this interface will take care of dealing with all the logic necessary to actually serialize the settings, store them to disk and then read them back. We can now use this service in our SubredditWidgetViewModel, in order to make the SelectedSubreddit property persistent:


Here we're using dependency injection and constructor injection, as mentioned above. We've declared an ISettingsService SettingsService field that just stores our settings service (which we're receiving as parameter in the viewmodel constructor), and then we're initializing the SelectedSubreddit property in the constructor, by either using the previous value or just the first available subreddit. Then we also modified the SelectedSubreddit setter, so that it will also use the settings service to save the new value to disk.


The last component of the backend that we're missing is a service that is able to use the Reddit REST APIs to fetch the posts from the subreddits we're interested in. To build it, we're going to use refit, which is a library to easily build type-safe services to interact with REST APIs. As before, we need to define the interface with all the APIs that our service will implement, like so:


Let's start with the subreddit widget, which features a ComboBox to select a subreddit, a Button to refresh the feed, a ListView to display posts and a ProgressBar to indicate when the feed is loading. We'll assume that the ViewModel property represents an instance of the viewmodel we've described before - this can be declared either in XAML or directly in code behind.


Here we're binding the source to the Subreddits property, and the selected item to the SelectedSubreddit property. Note how the Subreddits property is only bound once, as the collection itself sends change notifications, while the SelectedSubreddit property is bound with the TwoWay mode, as we need it both to be able to load the value we retrieve from our settings, as well as updating the property in the viewmodel when the user changes the selection. Additionally, we're using a XAML behavior to invoke our command whenever the selection changes.


Mars JullianI think, also, you need to consider sort of what clients you're catering to, because not all of them will support HTTP, two out of the gate. And I think over time, we'll be able, we can use, you know, new tools that come out more and more, but at the same time, we'll kind of have I mean, Franken says not quite the right word, but no new tools come out will be come part of the toolkit, not the single tool that solves like the single tool to solve the mall. We're catering to a lot of different people, different devices, different types of browsers on all versions, you know, it's, it's a whole crazy world out there, when you actually look at what different browsers people are using. 2ff7e9595c


0 views0 comments

Recent Posts

See All

Monkey smart watch app download

Download do aplicativo Monkey Smart Watch: como obter os melhores aplicativos para o seu smartwatch Se você possui um Monkey Smart Watch,...

youtube 6.0 apk

APK do YouTube 6.0: o que você precisa saber Introdução O YouTube é uma das plataformas de compartilhamento de vídeos mais populares do...

Comments


bottom of page