forked from ForNeVeR/xaml-math
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainWindow.xaml
69 lines (63 loc) · 3.43 KB
/
MainWindow.xaml
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
<Window x:Class="WpfMath.Example.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:WpfMath.Controls;assembly=WpfMath"
Title="WPF-Math Example" Width="640" Height="520"
Closed="Window_Closed">
<Window.Resources>
<Style TargetType="Button">
<Setter Property="Padding" Value="2" />
</Style>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<DockPanel Margin="10,10,10,0" Grid.Row="0" Grid.Column="0">
<ComboBox DockPanel.Dock="Left" Width="150"
Name="FormulaSelector" SelectionChanged="FormulaTextBox_OnSelectionChanged" />
<Button DockPanel.Dock="Right" Content="_Save"
Click="saveButton_Click" />
<TextBox Margin="10,0"
Name="InputTextBox" SelectionChanged="inputTextBox_SelectionChanged" />
</DockPanel>
<Label Margin="10,0,10,10" Grid.Row="1" Grid.Column="0">
<Label.Style>
<Style TargetType="Label">
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=Formula, Path=HasError}" Value="False">
<Setter Property="Content" Value="Formula is valid" />
<Setter Property="Foreground" Value="Green" />
</DataTrigger>
<DataTrigger Binding="{Binding ElementName=Formula, Path=HasError}" Value="True">
<Setter Property="Content" Value="{Binding ElementName=Formula, Path=Errors[0].Message}" />
<Setter Property="Foreground" Value="Red" />
</DataTrigger>
</Style.Triggers>
</Style>
</Label.Style>
</Label>
<Grid Margin="0,0,0,10" Grid.Row="2" Grid.Column="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Label Margin="10,0,10,0" Content="Scale: " Grid.Column="0" />
<Slider Margin="10,0,10,0" Grid.Column="1"
Value="{Binding ElementName=Formula, Path=Scale}" Minimum="7" Maximum="42"
IsSnapToTickEnabled="True" TickPlacement="BottomRight"
AutoToolTipPlacement="BottomRight" AutoToolTipPrecision="2" />
</Grid>
<Border Margin="10,0,10,10" BorderBrush="LightGray" BorderThickness="1" Grid.Row="3" Grid.Column="0">
<ScrollViewer Padding="4" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Disabled">
<controls:FormulaControl Name="Formula" Formula="{Binding Text, ElementName = InputTextBox, NotifyOnValidationError=True}"
SelectionBrush="LightBlue"
SystemTextFontName="Arial"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch" SnapsToDevicePixels="True" />
</ScrollViewer>
</Border>
</Grid>
</Window>