wpf-calculator/SimpleCalculator/MainWindow.xaml
2023-03-09 14:35:50 +01:00

209 lines
6.4 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<Window x:Class="SimpleCalculator.MainWindow"
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:vm="clr-namespace:SimpleCalculator"
mc:Ignorable="d"
Title="MainWindow" Height="600" Width="400">
<Window.Resources>
<vm:CalculatorMV x:Key="ViewModel" />
</Window.Resources>
<Grid DataContext="{StaticResource ViewModel}">
<Grid.RowDefinitions>
<RowDefinition Height="2*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Label
Grid.Column="0"
Grid.Row="0"
Grid.ColumnSpan="4"
Content="{Binding ResultText}"
Margin="10"
BorderBrush="Black"
BorderThickness="5"
Background="Green"
FontSize="56"
FontFamily="Consolas"
VerticalContentAlignment="Center"
HorizontalContentAlignment="Right"
/>
<Button
Grid.Column="0"
Grid.Row="1"
Grid.ColumnSpan="1"
Content="AC"
Style="{StaticResource SpecialButton}"
Command="{Binding acClickedCommand}"
/>
<Button
Grid.Column="1"
Grid.Row="1"
Grid.ColumnSpan="1"
Content="±"
Style="{StaticResource SpecialButton}"
Command="{Binding invertClickedCommand}"
/>
<Button
Grid.Column="2"
Grid.Row="1"
Grid.ColumnSpan="1"
Content="%"
Style="{StaticResource SpecialButton}"
Command="{Binding percentileClickedCommand}"
/>
<Button
Grid.Column="3"
Grid.Row="1"
Grid.ColumnSpan="1"
Content="÷"
Style="{StaticResource OperatorButton}"
Command="{Binding divideClickedCommand}"
/>
<Button
Grid.Column="3"
Grid.Row="2"
Grid.ColumnSpan="1"
Content="×"
Style="{StaticResource OperatorButton}"
Command="{Binding multiplyClickedCommand}"
/>
<Button
Grid.Column="3"
Grid.Row="3"
Grid.ColumnSpan="1"
Content="-"
Style="{StaticResource OperatorButton}"
Command="{Binding subtractClickedCommand}"
/>
<Button
Grid.Column="3"
Grid.Row="4"
Grid.ColumnSpan="1"
Content="+"
Style="{StaticResource OperatorButton}"
Command="{Binding addClickedCommand}"
/>
<Button
Grid.Column="3"
Grid.Row="5"
Grid.ColumnSpan="1"
Content="="
Style="{StaticResource OperatorButton}"
Command="{Binding equalClickedCommand}"
/>
<Button
Grid.Column="0"
Grid.Row="2"
Grid.ColumnSpan="1"
Command="{Binding numberClickedCommand}"
CommandParameter="7"
Content="7"
Style="{StaticResource NumberButton}"
/>
<Button
Grid.Column="1"
Grid.Row="2"
Grid.ColumnSpan="1"
Command="{Binding numberClickedCommand}"
CommandParameter="8"
Content="8"
Style="{StaticResource NumberButton}"
/>
<Button
Grid.Column="2"
Grid.Row="2"
Grid.ColumnSpan="1"
Command="{Binding numberClickedCommand}"
CommandParameter="9"
Content="9"
Style="{StaticResource NumberButton}"
/>
<Button
Grid.Column="0"
Grid.Row="3"
Grid.ColumnSpan="1"
Command="{Binding numberClickedCommand}"
CommandParameter="4"
Content="4"
Style="{StaticResource NumberButton}"
/>
<Button
Grid.Column="1"
Grid.Row="3"
Grid.ColumnSpan="1"
Command="{Binding numberClickedCommand}"
CommandParameter="5"
Content="5"
Style="{StaticResource NumberButton}"
/>
<Button
Grid.Column="2"
Grid.Row="3"
Grid.ColumnSpan="1"
Command="{Binding numberClickedCommand}"
CommandParameter="6"
Content="6"
Style="{StaticResource NumberButton}"
/>
<Button
Grid.Column="0"
Grid.Row="4"
Grid.ColumnSpan="1"
Command="{Binding numberClickedCommand}"
CommandParameter="1"
Content="1"
Style="{StaticResource NumberButton}"
/>
<Button
Grid.Column="1"
Grid.Row="4"
Grid.ColumnSpan="1"
Command="{Binding numberClickedCommand}"
CommandParameter="2"
Content="2"
Style="{StaticResource NumberButton}"
/>
<Button
Grid.Column="2"
Grid.Row="4"
Grid.ColumnSpan="1"
Command="{Binding numberClickedCommand}"
CommandParameter="3"
Content="3"
Style="{StaticResource NumberButton}"
/>
<Button
Grid.Column="0"
Grid.Row="5"
Grid.ColumnSpan="2"
Command="{Binding numberClickedCommand}"
CommandParameter="0"
Content="0"
Style="{StaticResource NumberButton}"
/>
<Button
Grid.Column="2"
Grid.Row="5"
Grid.ColumnSpan="1"
Content=","
Style="{StaticResource NumberButton}"
Command="{Binding decimalPointClickedCommand}"
/>
</Grid>
</Window>