JasinCole
Well-known member
- Joined
- Feb 16, 2023
- Messages
- 66
- Programming Experience
- 1-3
This is another ones of those problems that I just don't know the best way to handle/best practice.
I'm posting this here because it has to do with xaml code in avalonia, but I do not think this is specific to that project.
Let's say I have the following xaml, and in the VM I have a dictionary named Accounts. The Dict<Key (is the account number),Value (is the balance)>.
The reason I am doing the below is a Dictionaries order is not guaranteed and I want to display the information in a similar fashion everytime. But instead of making hundreds of calls to the DB I am making just one that is returning all accounts I ask for with just the account number and balance and assigning that to a dictionary.
With the above I can call Accounts[acctnum] as below. But this seems not very expressive and what happens if I want to change the account numbers and import them at runtime?
I'm posting this here because it has to do with xaml code in avalonia, but I do not think this is specific to that project.
Let's say I have the following xaml, and in the VM I have a dictionary named Accounts. The Dict<Key (is the account number),Value (is the balance)>.
The reason I am doing the below is a Dictionaries order is not guaranteed and I want to display the information in a similar fashion everytime. But instead of making hundreds of calls to the DB I am making just one that is returning all accounts I ask for with just the account number and balance and assigning that to a dictionary.
With the above I can call Accounts[acctnum] as below. But this seems not very expressive and what happens if I want to change the account numbers and import them at runtime?
C#:
<Grid ColumnDefinitions="*, Auto">
<TextBlock Grid.Column="0" Text="General Checking" />
<TextBlock
Grid.Column="1"
Text="{CompiledBinding Accounts[1000], FallbackValue=0}" />
</Grid>