✅ Does this styling code look right?
I'm using this code for a simple hover effect. Im wondering if I'm doing this correctly:
<Window.Resources>
<Style TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border Background="{TemplateBinding Background}">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Green"/>
</Trigger>
</Style.Triggers>
</Style>
</Window.Resources>
K
kuulie•400d ago
could someone please explain this snippet of code to me? i noticed the hover effect only works when i add this: <Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Background="{TemplateBinding Background}">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
im very noob
i read the docs on ControlTemplate and am still somewhat confused
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
52KMembers
View on DiscordWant results from more Discord servers?
More Posts❔ ?[] operator for dictionariesIs not working. It is explained here. https://learn.microsoft.com/en-us/dotnet/csharp/language-refer❔ IAsyncEnumerable vs List<T> as parameter in methodI have a method that is overloaded and will take in a List<T> or IAsyncEnumerable. The method will b❔ This code is bugged how can i solve it?```LogiwaEntities1 db = new LogiwaEntities1();
ProductData productData = new ProductData✅ How to add hover effect to WPF button elementThis code I'm using isn't working. When I hover over buttons its a lightblue color.
<Style with or without refso i learned that in c#(or most oop languages) when you create a method that takes an object as a pa✅ .net trying to find non-existent cs files`Error IDE1100 Error reading content of source file 'D:\Dev\C++\Test\TestCS\obj\Debug\net6.0\.❔ WPF - Binding to last child of collectionI have the following setup:
```csharp
public partial class StatusMessageService : ObservableObject
✅ What does WPF want from me?I'm actually so tired of WPF and MVVM and all this contrived fuckin bs you guys
MainWindow control: