C
C#ā€¢2mo ago
Dan

What is the correct ternary operation here?

I cannot "assign" values in ternary operations?
No description
28 Replies
Servator
Servatorā€¢2mo ago
ternary for assignment not comparison but if you put inside () it could work i think put right side of == in ()
leowest
leowestā€¢2mo ago
Application.Current.MainWindow.WindowState = _windowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized;
Application.Current.MainWindow.WindowState = _windowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized;
Servator
Servatorā€¢2mo ago
Also you are complicating Just use switch expression
leowest
leowestā€¢2mo ago
to me it looks like you're trying to assing the wrong thing no?
Servator
Servatorā€¢2mo ago
When i look to your code i dont get what you are trying to do
Dan
DanOPā€¢2mo ago
yeah
Dan
DanOPā€¢2mo ago
No description
leowest
leowestā€¢2mo ago
šŸ‘†
Servator
Servatorā€¢2mo ago
Application.Current.MainWindow.WindowState = WindowState.Minimize; ?
Servator
Servatorā€¢2mo ago
No description
Servator
Servatorā€¢2mo ago
Yeah But command is maximize command Yeah that's what im trying to explain
leowest
leowestā€¢2mo ago
It would be a MaximizeRestoreWindowCommand as is anyway the problem is that his code and ternary are wrong like I pointed out
Dan
DanOPā€¢2mo ago
I guess this would be better?
No description
Dan
DanOPā€¢2mo ago
more readable and they are separate a command for each button
leowest
leowestā€¢2mo ago
you could do that yes, and since the button is named Minimized and the other Maximize it would make more sense
Dan
DanOPā€¢2mo ago
yep, great šŸ‘
Servator
Servatorā€¢2mo ago
Also what's the type of "o" ? Maybe you can use that too
Dan
DanOPā€¢2mo ago
object
Servator
Servatorā€¢2mo ago
It's probably boxed to object nvm just dont care then šŸ˜„
Dan
DanOPā€¢2mo ago
hmm
leowest
leowestā€¢2mo ago
you should look into using CommunityToolkit.Mvvm it will reduce and simplify a lot of your code
Dan
DanOPā€¢2mo ago
how can i check not .Equals?
Servator
Servatorā€¢2mo ago
You could put "!" start of it or simply "is not x"
Dan
DanOPā€¢2mo ago
Is this valid?
No description
leowest
leowestā€¢2mo ago
we would need to know what o is first, u would have to breakpoint and check its insides since you're using a RelayCommand it might depend how it was setup and what its passing over
Servator
Servatorā€¢2mo ago
Looks like it's an action but im not so sure
BlyZe
BlyZeā€¢2mo ago
You could just do this:
Application.Current.MainWindow.WindowState = WindowState.Maximized;
Application.Current.MainWindow.WindowState = WindowState.Maximized;
The check doesn't make much sense there
Servator
Servatorā€¢2mo ago
Problem is Command is MaximizeWindowCommand so it should minimize
Want results from more Discord servers?
Add your server