added samples
[windows-sources.git] / sdk / samples / WPFSamples / DialogBoxSample / visualbasic / marginsdialogbox.xaml
blob7259e35357620be0c40706f1e8d445aa8ff7c6d3
1 <Window 
2     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4     x:Class="SDKSample.MarginsDialogBox"
5     xmlns:local="clr-namespace:SDKSample"
6     Title="Margins"
7     Height="190"
8     Width="300"
9     MinHeight="10"
10     MinWidth="300"
11     ResizeMode="CanResizeWithGrip"
12     ShowInTaskbar="False"
13     WindowStartupLocation="CenterOwner" 
14     FocusManager.FocusedElement="{Binding ElementName=leftMarginTextBox}">
16   <Grid>
17     <Grid.Resources>
18       <Style TargetType="{x:Type Grid}">
19         <Setter Property="Margin" Value="10" />
20       </Style>
21       <Style TargetType="{x:Type Label}">
22         <Setter Property="Margin" Value="0,3,5,5" />
23         <Setter Property="Padding" Value="0,0,0,5" />
24       </Style>
25       <Style TargetType="{x:Type TextBox}">
26         <Setter Property="Margin" Value="0,0,0,5" />
27         <Style.Triggers>
28           <Trigger Property="Validation.HasError" Value="true">
29             <Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}"/>
30           </Trigger>
31         </Style.Triggers>
32       </Style>
33       <Style TargetType="{x:Type StackPanel}">
34         <Setter Property="Orientation" Value="Horizontal" />
35         <Setter Property="HorizontalAlignment" Value="Right" />
36       </Style>
37       <Style TargetType="{x:Type Button}">
38         <Setter Property="Width" Value="70" />
39         <Setter Property="Height" Value="25" />
40         <Setter Property="Margin" Value="5,0,0,0" />
41       </Style>
42     </Grid.Resources>
44     <Grid.ColumnDefinitions>
45       <ColumnDefinition Width="Auto" />
46       <ColumnDefinition />
47     </Grid.ColumnDefinitions>
49     <Grid.RowDefinitions>
50       <RowDefinition Height="Auto" />
51       <RowDefinition Height="Auto" />
52       <RowDefinition Height="Auto" />
53       <RowDefinition Height="Auto" />
54       <RowDefinition Height="Auto" />
55       <RowDefinition />
56     </Grid.RowDefinitions>
58     <!-- Left Margin -->
59     <Label Grid.Column="0" Grid.Row="0">Left Margin:</Label>
60     <TextBox Name="leftMarginTextBox" Grid.Column="1" Grid.Row="0">
61       <TextBox.Text>
62         <Binding Path="Left" UpdateSourceTrigger="PropertyChanged">
63           <Binding.ValidationRules>
64             <local:MarginValidationRule MinMargin="0" MaxMargin="10" />
65           </Binding.ValidationRules>
66         </Binding>
67       </TextBox.Text>
68     </TextBox>
70     <!-- Top Margin -->
71     <Label Grid.Column="0" Grid.Row="1">Top Margin:</Label>
72     <TextBox Name="topMarginTextBox" Grid.Column="1" Grid.Row="1">
73       <TextBox.Text>
74         <Binding Path="Top" UpdateSourceTrigger="PropertyChanged">
75           <Binding.ValidationRules>
76             <local:MarginValidationRule MinMargin="0" MaxMargin="10" />
77           </Binding.ValidationRules>
78         </Binding>
79       </TextBox.Text>
80     </TextBox>
82     <!-- Right Margin -->
83     <Label Grid.Column="0" Grid.Row="2">Right Margin:</Label>
84     <TextBox Name="rightMarginTextBox" Grid.Column="1" Grid.Row="2">
85       <TextBox.Text>
86         <Binding Path="Right" UpdateSourceTrigger="PropertyChanged">
87           <Binding.ValidationRules>
88             <local:MarginValidationRule MinMargin="0" MaxMargin="10" />
89           </Binding.ValidationRules>
90         </Binding>
91       </TextBox.Text>
92     </TextBox>
94     <!-- Bottom Margin -->
95     <Label Grid.Column="0" Grid.Row="3">Bottom Margin:</Label>
96     <TextBox Name="bottomMarginTextBox" Grid.Column="1" Grid.Row="3">
97       <TextBox.Text>
98         <Binding Path="Bottom" UpdateSourceTrigger="PropertyChanged">
99           <Binding.ValidationRules>
100             <local:MarginValidationRule MinMargin="0" MaxMargin="10" />
101           </Binding.ValidationRules>
102         </Binding>
103       </TextBox.Text>
104     </TextBox>
106     <!-- Accept or Cancel -->
107     <StackPanel Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="4">
108       <Button Name="okButton" Click="okButton_Click" IsDefault="True">OK</Button>
109       <Button Name="cancelButton" IsCancel="True">Cancel</Button>
110     </StackPanel>
112   </Grid >
113 </Window>