Request per Leowest. Trouble with editor text

BlazeBin - hguhcslxesnu
A tool for sharing your source code with the world!
6 Replies
Absent_Reality
Absent_RealityOP10mo ago
@leowest lmk if you need more info.
Omnissiah
Omnissiah10mo ago
⁉️
leowest
leowest10mo ago
just got bac k will look in a few @Absent_Reality first I will stress u should really use MVVM instead of this approach this is not winform, it works differently and u will go down a even worse path going this route as your code base grows. You would first setup in MauiProgram.cs these 2 lines:
builder.Services.AddSingleton<MainPage>();
builder.Services.AddSingleton<Logs>();
builder.Services.AddSingleton<MainPage>();
builder.Services.AddSingleton<Logs>();
Then you would add the following to MainPage
private Logs _logs;

public MainPage(Logs logs)
{
InitializeComponent();
_logs = logs;
}
private Logs _logs;

public MainPage(Logs logs)
{
InitializeComponent();
_logs = logs;
}
Now you should be able to call your button with
private async void btn_Home_Clicked(object sender, EventArgs e)
{
await _logs.LogThis("Home Pressed.");
}
private async void btn_Home_Clicked(object sender, EventArgs e)
{
await _logs.LogThis("Home Pressed.");
}
And on Logs you would need
public async Task LogThis(string text)
{
Logtext.Text += message;
}
public async Task LogThis(string text)
{
Logtext.Text += message;
}
Again I do not suggest you do things in this way, I strongly advise you to learn MVVM its not that mythic monster you're sounding it to be Or at the very least how to use DataContext instead even if not MVVM
Absent_Reality
Absent_RealityOP10mo ago
@leowest I will do so. Just started learning programming not very long ago, so I'm learning everything I can lol. Thanks for the help!
leowest
leowest10mo ago
no worries, if u feel like learning MVVM feel free to reach me out of just open another help anyone here would help u with open arms, but the above is just not worth it. if this answer your question feel free to do a /close later
Absent_Reality
Absent_RealityOP10mo ago
/close Oops lol
Want results from more Discord servers?
Add your server