saed2006
پنج شنبه 03 شهریور 1390, 11:25 صبح
رويدادي كه براي textbox
اجرا نميشه
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:WpfApplication21_Views="clr-namespace:WpfApplication21.Views"
mc:Ignorable="d"
x:Class="WpfApplication21.NUMBERIC"
x:Name="UserControl"
d:DesignWidth="133" d:DesignHeight="25">
<UserControl.Resources>
<WpfApplication21_Views:Them x:Key="ThemDataSource" d:IsDataSource="True"/>
<Style x:Key="{x:Type TextBoxBase}" TargetType="{x:Type TextBoxBase}">
<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
<Setter Property="BorderBrush" Value="{StaticResource ListBorder}"/>
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
<Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="HorizontalContentAlignment" Value="Left"/>
<Setter Property="Padding" Value="2"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="AllowDrop" Value="true"/>
<Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
<Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBoxBase}">
<Border x:Name="Bd" SnapsToDevicePixels="true" CornerRadius="10" BorderThickness="2" Background="{Binding cbrush}" BorderBrush="{Binding myBrushborder}">
<ScrollViewer x:Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Background="{x:Null}" BorderBrush="{x:Null}" Foreground="{x:Null}"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="{x:Type Hyperlink}" TargetType="{x:Type Hyperlink}">
<Setter Property="Foreground" Value="Blue"/>
<Setter Property="TextDecorations" Value="Underline"/>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Foreground" Value="Red"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
</Trigger>
<Trigger Property="IsEnabled" Value="true">
<Setter Property="Cursor" Value="Hand"/>
</Trigger>
</Style.Triggers>
</Style>
<Style x:Key="RichTextBoxStyle1" TargetType="{x:Type RichTextBox}">
<Style.Resources>
<Style x:Key="{x:Type FlowDocument}" TargetType="{x:Type FlowDocument}">
<Setter Property="OverridesDefaultStyle" Value="true"/>
</Style>
<Style x:Key="{x:Type Hyperlink}" BasedOn="{StaticResource {x:Type Hyperlink}}" TargetType="{x:Type Hyperlink}">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Foreground" Value="Blue"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
</Trigger>
</Style.Triggers>
</Style>
</Style.Resources>
<Setter Property="MinWidth" Value="10"/>
<Style.BasedOn>
<StaticResource ResourceKey="{x:Type TextBoxBase}"/>
</Style.BasedOn>
</Style>
</UserControl.Resources>
<Border BorderBrush="{Binding myBrushborder}" CornerRadius="12" BorderThickness="2" DataContext="{Binding Source={StaticResource ThemDataSource}}">
<Grid x:Name="LayoutRoot">
<TextBox Name="a" KeyDown="a_KeyDown" PreviewKeyDown="TextBox_PreviewKeyDown" Foreground="{Binding fbrush}" BorderThickness="0" Margin="2" Background="{Binding cbrush}" BorderBrush="{x:Null}"/>
</Grid>
</Border>
</UserControl>
اجرا نميشه
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:WpfApplication21_Views="clr-namespace:WpfApplication21.Views"
mc:Ignorable="d"
x:Class="WpfApplication21.NUMBERIC"
x:Name="UserControl"
d:DesignWidth="133" d:DesignHeight="25">
<UserControl.Resources>
<WpfApplication21_Views:Them x:Key="ThemDataSource" d:IsDataSource="True"/>
<Style x:Key="{x:Type TextBoxBase}" TargetType="{x:Type TextBoxBase}">
<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
<Setter Property="BorderBrush" Value="{StaticResource ListBorder}"/>
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
<Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="HorizontalContentAlignment" Value="Left"/>
<Setter Property="Padding" Value="2"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="AllowDrop" Value="true"/>
<Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
<Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBoxBase}">
<Border x:Name="Bd" SnapsToDevicePixels="true" CornerRadius="10" BorderThickness="2" Background="{Binding cbrush}" BorderBrush="{Binding myBrushborder}">
<ScrollViewer x:Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Background="{x:Null}" BorderBrush="{x:Null}" Foreground="{x:Null}"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="{x:Type Hyperlink}" TargetType="{x:Type Hyperlink}">
<Setter Property="Foreground" Value="Blue"/>
<Setter Property="TextDecorations" Value="Underline"/>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Foreground" Value="Red"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
</Trigger>
<Trigger Property="IsEnabled" Value="true">
<Setter Property="Cursor" Value="Hand"/>
</Trigger>
</Style.Triggers>
</Style>
<Style x:Key="RichTextBoxStyle1" TargetType="{x:Type RichTextBox}">
<Style.Resources>
<Style x:Key="{x:Type FlowDocument}" TargetType="{x:Type FlowDocument}">
<Setter Property="OverridesDefaultStyle" Value="true"/>
</Style>
<Style x:Key="{x:Type Hyperlink}" BasedOn="{StaticResource {x:Type Hyperlink}}" TargetType="{x:Type Hyperlink}">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Foreground" Value="Blue"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
</Trigger>
</Style.Triggers>
</Style>
</Style.Resources>
<Setter Property="MinWidth" Value="10"/>
<Style.BasedOn>
<StaticResource ResourceKey="{x:Type TextBoxBase}"/>
</Style.BasedOn>
</Style>
</UserControl.Resources>
<Border BorderBrush="{Binding myBrushborder}" CornerRadius="12" BorderThickness="2" DataContext="{Binding Source={StaticResource ThemDataSource}}">
<Grid x:Name="LayoutRoot">
<TextBox Name="a" KeyDown="a_KeyDown" PreviewKeyDown="TextBox_PreviewKeyDown" Foreground="{Binding fbrush}" BorderThickness="0" Margin="2" Background="{Binding cbrush}" BorderBrush="{x:Null}"/>
</Grid>
</Border>
</UserControl>