how do we store and retrieve data from Dictionary in .NET MAUI Blazor app, and is it possible to perfrom localization using IStringLocalizer and dictionary

Anonymous
2022-12-19T12:16:32.787+00:00
protected async Task OnInitializedAsync(){  
    Dictionary<string, object> properties = new Dictionary<string, object>();  
    properties.Add("Hello", "Greetings");  
}   

how do we show it on the screen when we use it in index.razor page

Developer technologies | .NET | .NET MAUI
Developer technologies | C#
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. Anonymous
    2022-12-20T07:05:50.843+00:00

    Hello,

    how do we show it on the screen when we use it in index.razor page

    You can use @properties to get this Dictionary in your blazor page, I show it on the screen by <p>, here is my index.razor page for testing.

       @page "/"  
         
       <h1>Hello, world!</h1>  
         
       Welcome to your new app.  
         
       <SurveyPrompt Title="How is Blazor working for you?" />  
       <a>  
           @foreach (KeyValuePair <string, object> kvp in properties)  
           {  
               <p>@kvp.Key</p>  
               <p>@kvp.Value</p>  
           }  
           @properties.GetValueOrDefault("Hello");  
       </a>  
         
         
       @code{  
           Dictionary<string, object> properties;  
           protected override async Task OnInitializedAsync()  
           {  
               properties = new Dictionary<string, object>();  
               properties.Add("Hello", "Greetings");  
         
          }  
       }  
    

    As note: Ask one question at a time, you can open a new thread about localization.

    Best Regards,

    Leon Lu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.