PostgreSQL in Azure
Last Month, I went to the Brisbane.net user group. The topic is PostgreSQL.PostgreSQL? How can it be related to .Net? You may think that that is more related to Linux. That is not. Azure got Postsqesql implementation, which is customized for Azure. Thus, that is performance quite good.
Moreover, that is more than half the price of the MS SQL server option. Lastly, EF core is fully supported by Postgresql. They are very suitable for a small-scale project. I will explore it for my membership management system.
Best way to download in MAUI
Due to the discontinuation of Google Podcasts, I am writing my own Podcast App for Android. I chose C# MAUI because I am a C# Developer, and I have used Xamarin (become a part of MAUI now) for years.
My first problem is the Podcast App; I need to load the RSS (XML) via HTTP. That is so easy. Same as other C# programs. Also, you can use to load any JSON information in different use case
Code
var client = new HttpClient(); | |
var string1 = client.GetStringAsync("https://podcast.rthk.hk/podcast/novamanage.xml").Result; | |
// deserailize |
PieChart of LiveChart
For using the PieChart, that is very easy, you just need to bind the series collection
Then I just need to get the data from my repo:
var categories = new ObservableCollection(_database.BudgetCategories.GetAllCategories());
SeriesCollection = new SeriesCollection();
foreach (var category in categories)
{
var budgetItems = new ObservableCollection(_database.BudgetItems.GetItemByCategory(category));
double amount = 0;
foreach (var item in budgetItems)
{
amount += (double) item.Amount;
}
var pieSeries = new PieSeries
{
Title = category.Name,
Values = new ChartValues { new ObservableValue(amount) },
DataLabels = true
};
SeriesCollection.Add(pieSeries);
}
}
Charting Tool for WPF
Recently, we have been buying a WPF application. That is a budget management application. That is talking about money. Of course, charts need to play an important role. I have looked into various charting libraries. Some of them need to be paid. However, one is entirely open and completed under an MIT license. That does not require access to their AP. Charting is done locally. It supports everything, such as MAUI, Wpf, Winforms, and ASP.net. In addition, the documentation is alright. That is Live Charts.
Solution for WPF Combo Box binding with a object type value
I found that the ComboBox WPF binding in WPF does not work correctly if the binding value is of an object type. Even when I set SelectedValuePath="Id", the binding fails to set the value. When a different value in the ComboBox is selected, the new selected value should be set in the ViewModel too. However, this does not happen this way.
I got a solution for this issue, which is to set the SelectedValue to be the CategoryId:
<ComboBox Grid.Row="3" Grid.Column="1" ItemsSource="{Binding CategoryList}" DisplayMemberPath="Name" SelectedItem="CategoryId" SelectedValue="{Binding CategoryId, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" SelectedValuePath="Id" Margin="5"/>
Inside the ViewModel:
public int CategoryId { get => _selectedCategoryId; set { if (_selectedCategoryId != value) { //_selectedCategory = value; _item.CategoryId = value; _item.Category = CategoryList.FirstOrDefault(c => c.Id == value); OnPropertyChanged(); } } }
Then it will work!