how to make it so when u hover on button it turn blue and when you not it turn back to white
serched on google didnt found it, just start blue all the timer
25 Replies
private void button1_enter(object sender, EventArgs e)
{
} //code /code !code
} //code /code !code
Winforms? WPF? Avalonia? Blazor?
wpf
@leowest I summon thee
hi there
hi
u have to write a trigger
I think I have an example moment
bet, would help
like trigger class?
The ControlTemplate is what changes the IsMouseOver and IsPressed events on the button
all this to color it blue?
damn got some work
when u hover it yes
ofc in this example its not blue but yeah
trigger class?
?
nvm
u write this in xaml
not in c# code
that whole mostruocity is the button
if its too confusing let me know I can try to explain the proccess of doing this
that only way?
no way doing it using
private void button1_enter(object sender, EventArgs e)
{
}
havnt learn xaml yet, just started wpf
well WPF is not WinForms u dont drag, drop, move the controls using the designer
you write the controls via XAML its the most important part of it to keep your design consistent
$rulesofwpf
when using the designer and moving things around it will generate a lot of garbage code margins for example that can place your controls out of bounds of visibility
@RANI I suggest you take a trip on this site https://wpf-tutorial.com/
its great if u are just starting with WPF, it will show u all the various controls
how to write XAML
how most of the controls work and their purpose
That command had an error
UnknownCommand: Unknown command.
Remove your reaction to delete this message
Maybe you didn't find it because you dont provide it with enough context to go for
You can't simply write
how to make button go blue
, you need to specify the framework you are using and what language you want it in. Also don't type long sentences into google, summarize what you want very short.I think the confusion comes from the fact he wanted to do it from code only, and XAML is a bit different
ye i try to do it code only
u would have to write dependencies that would be a lot more than just messing with the xaml
to change templates
certain things u can certainly do from code when its publicly available
some require a major workaround to reach it
for example <button x:Name="MyButton" />
now u can access MyButton from code and do say MyButton.Foreground and change the text color
but there is a limit of how much u can access without having to resort to reflection and whatnot
if u were to write from c# u would have to write a Style, extract the ControlTemplate, recreate the triggers, and apply to the button
and that is not trivial