1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
|
<Window x:Class="Utils.Dialogs.InputDialog"
x:Name="inputDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:val="clr-namespace:Utils.ValidationRules"
Title="{Binding ElementName=inputDialog, Path=Title}"
Icon="pack://application:,,,/Images/16x16/edit.png"
FontSize="12"
Background="Transparent"
SizeToContent="WidthAndHeight"
ResizeMode="NoResize"
WindowStyle="None"
AllowsTransparency="True"
ShowInTaskbar="False"
WindowStartupLocation="CenterOwner"
FocusManager.FocusedElement="{Binding ElementName=txtValue}">
<Window.Resources>
<!-- Template used to display a picture after the textbox in order to warn for error messages -->
<ControlTemplate x:Key="validationTemplate">
<DockPanel>
<AdornedElementPlaceholder />
<Image Source="pack://application:,,,/Images/16x16/flag.png"
Width="16"
Height="16"
Margin="3,0,0,0"/>
</DockPanel>
</ControlTemplate>
<!-- Style used to display error messages in a tooltip -->
<Style x:Key="textBoxInError"
TargetType="{x:Type TextBox}">
<Style.Triggers>
<Trigger Property="Validation.HasError"
Value="true">
<Setter Property="ToolTip"
Value="{Binding ElementName=txtValue, Path=(Validation.Errors).CurrentItem}" />
<Setter Property="ToolTip.IsOpen"
Value="True" />
<Setter Property="ToolTip.StaysOpen"
Value="True" />
<Setter Property="BitmapEffect">
<Setter.Value>
<OuterGlowBitmapEffect GlowColor="Red"
GlowSize="2" />
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
</Window.Resources>
<Border CornerRadius="12,12,12,12"
BorderBrush="#FF020202"
BorderThickness="0,0,0,0"
Height="Auto">
<Border.Background>
<LinearGradientBrush StartPoint="0,0"
EndPoint="1,1">
<GradientStop Color="LightSteelBlue"
Offset="0.0" />
<GradientStop Color="White"
Offset="0.5" />
<GradientStop Color="LightSteelBlue"
Offset="1.0" />
</LinearGradientBrush>
</Border.Background>
<StackPanel Orientation="Vertical">
<!-- Input part -->
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Center"
Margin="30,15,30,0">
<Label Content="{Binding ElementName=inputDialog, Path=DialogLabel}"
Margin="0,0,5,0" />
<TextBox x:Name="txtValue"
Width="50"
Validation.ErrorTemplate="{StaticResource validationTemplate}"
Style="{StaticResource textBoxInError}">
<TextBox.Text>
<Binding ElementName="inputDialog"
Path="Value"
Mode="TwoWay"
UpdateSourceTrigger="PropertyChanged"
ValidatesOnDataErrors="True">
</Binding>
</TextBox.Text>
</TextBox>
</StackPanel>
<!-- Buttons part -->
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Center"
Margin="30,15,30,15">
<Button x:Name="btnOk"
Content="OK"
Width="70"
Height="25"
Margin="0,0,5,0"
IsDefault="True"
Click="btnOkClick" />
<Button x:Name="btnCancel"
Content="Cancel"
Width="70"
Height="25"
Margin="5,0,0,0"
IsCancel="True"
Click="btnCancelClick" />
</StackPanel>
</StackPanel>
</Border>
</Window> |
Partager