Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to Trigger Click Event in WPF User control (Textbox with Button)?
    primarykey
    data
    text
    <p>I have Created one User control for WPF Like Windows 8 Password box Model. </p> <p>My UserControl XAML Code -</p> <pre><code> &lt;Grid.Resources&gt; &lt;Style x:Key="ButtonWithoutHover" TargetType="Button"&gt; &lt;Setter Property="OverridesDefaultStyle" Value="True"/&gt; &lt;Setter Property="Margin" Value="0"/&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="Button"&gt; &lt;Border Name="border" BorderThickness="0" Background="{TemplateBinding Background}"&gt; &lt;ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" /&gt; &lt;/Border&gt; &lt;ControlTemplate.Triggers&gt; &lt;Trigger Property="IsMouseOver" Value="True"&gt; &lt;Setter TargetName="border" Property="BorderBrush" Value="Black" /&gt; &lt;/Trigger&gt; &lt;/ControlTemplate.Triggers&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; &lt;/Grid.Resources&gt; &lt;Border BorderBrush="Black" BorderThickness="2" &gt; &lt;DockPanel Canvas.Right="2" Canvas.Top="2"&gt; &lt;Button Style="{StaticResource ButtonWithoutHover}" Height="25" Width="20" BorderThickness="3" BorderBrush="White" DockPanel.Dock="Right" Background="CadetBlue" &gt; &lt;Button.Content&gt; &lt;Label Content="-&gt;" Foreground="White" /&gt; &lt;/Button.Content&gt; &lt;/Button&gt; &lt;TextBox Height="30" Width="180" FontSize="18" BorderThickness="0" Name="txtNumber" DockPanel.Dock="Left" &gt; &lt;/TextBox&gt; &lt;/DockPanel&gt; &lt;/Border&gt; </code></pre> <p><img src="https://i.stack.imgur.com/tPiwV.jpg" alt="enter image description here"></p> <p>Edit 1:</p> <p>I have include this Usercontrol in My project. But at the time of Implementing UserControl in Wpf Application There is No Click Event for my UserControl. So I add Click="UserControl1_Click" to Xaml. But It through an Error </p> <blockquote> <p>The property 'Click' does not exist in XML namespace 'clr-namespace:NumericTextbox;assembly=NumericTextbox'.</p> </blockquote> <p>My Application Xaml Code- </p> <pre><code>&lt;Window x:Class="NumericAppication.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:NumText="clr-namespace:NumericTextbox;assembly=NumericTextbox" Title="MainWindow" Height="350" Width="525"&gt; &lt;Grid&gt; &lt;NumText:UserControl1 Width="120" Height="30" Click="UserControl1_Click" /&gt; &lt;/Grid&gt; &lt;/Window&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload