❔ How To Use Saved String Data As ButtonLabel Content
Hi
I'm fairly new to C#/XAML, however not necessarily new to coding in general (using Visual Studio).
I'm building a game launcher of some sort, and I'm trying to display a button content with saved string data, so that its displayed to the user each time the window is displayed.
I get my string data from my SQL database
And I want to use the data inside char1/char2/char3 as button content
However in doing this, I have failed multiple times
My code starting off, basically what I expected the end result to be:
where UserIDLoggedIn = Label and CharSlot1,2,3 = Buttons, and UGCLauncher.userId, UGCLauncher.char1... = strings with stored values inside
I've tried multiple attempts at binding but none seem to generate the end result I need.
Here is the XAML code:
Attached is picture of what happens in the application (char1, char2, and char3 data isnt displayed as content)
im fairly new and i feel like its something really obvious im missing ;;
10 Replies
the strings you assign seem to be empty
also you're checking for empty strings in your conditions, use
string.IsNullOrEmpty
(strings are reference types, not just slices like span)once the sql function runs the strings return with values inside of them converted into string, and this function runs before the application loads into this window
I mean when you assign
Content
does every window load at once when u start an application ? if it does i think im having a serious 5head moment
idk it depends how you load it
but it's single-threaded most likely
unless you do something weird
oh i thought it does .... and thought u meant when the application start, then this function also starts
which is why the strngs would be empty
static constructors run lazily when the class is first accessed
if that's what you mean
I did a small test on my side... turns out they were initially empty in the first place
yeah using a debugger for this is usually the way to go
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.