Reputation: 36080
I need to create a custom checkBox control. So far I have:
So at the root instead of having UserControl or Window I have Checkbox. (On my code behind I inherit from CheckBox in order for this to work)
When I make that change I get the box that I highlighted on the first image. I do not want to have that box.
Also I will like to overide the functionality of the checkbox control. I will like for it to be checked when I click on the image that shows the 0 or 1. Right now if I click outside the image on the shade of the square for example I will fire the Cheked event. How can I overide that functionality? I already have my own animations that trigger when the mouse enters the number image and also when the mouse is down etc.
The reason why I avoided having visual states is because I need to fire events when the mouse enters a spesific image not any part of the control. In other words when using the visual states and I applied a style for the mouse over event that event fired if I placed my mouse anywhere inside the usercontrol.
Upvotes: 0
Views: 509
Reputation: 17145
<CheckBox x:Class="WpfApplication1.MyCustomCheckBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<CheckBox.Template>
<ControlTemplate>
<TextBlock>Whatever</TextBlock>
</ControlTemplate>
</CheckBox.Template>
</CheckBox>
Upvotes: 1