Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,786 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
A community member has associated this post with a similar question:
I can't change property of a button....
Only moderators can edit this content.
Hello,
I wrote a small app has 1 datepicker, 2 textboxes, 2 buttons.
here's the XAML code for app UI:
<Window x:Class="WpfApp3.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:local="clr-namespace:WpfApp3"
xmlns:model ="clr-namespace:WpfApp3.Model"
xmlns:viewModel ="clr-namespace:WpfApp3.ViewModel"
mc:Ignorable="d"
Background="AliceBlue"
ResizeMode="NoResize"
Title="MainWindow" Height="400" Width="350">
<Window.DataContext>
<viewModel:MainViewModel/>
</Window.DataContext>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="1.5*"/>
<RowDefinition Height="1.5*"/>
<RowDefinition Height="1.5*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="1.8*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" x:Name="Date" Text="Date:" FontSize="20" FontWeight="Bold" Margin="10,10,10,10" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<DatePicker x:Name="getdate" SelectedDate="{Binding SelectedDate}" Grid.Column="1" Width="200" Height="20" Margin="10,10,10,10" />
</Grid>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="1.8*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" x:Name="Item" Text="Item:" FontSize="20" FontWeight="Bold" Margin="10,40,10,40" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBox Grid.Column="1" FontSize="14" Text="{Binding Item}" Margin="10,40,10,40"/>
</Grid>
<Grid Grid.Row="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="1.8*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" x:Name="Amount" Text="Amount:" FontSize="20" FontWeight="Bold" Margin="10,40,10,40" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBox Grid.Column="1" FontSize="14" Text="{Binding Amount}" Margin="10,40,10,40"/>
</Grid>
<Grid Grid.Row="3">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button Grid.Column="0" Content="ShowInput" Command="{Binding getInputCommand}" FontSize="14" FontWeight="Bold" Margin="20,10,20,10"/>
<Button Grid.Column="1" Content="Clear" FontSize="14" Command="{Binding ClearCommand}" FontWeight="Bold" Margin="20,10,20,10"/>
</Grid>
</Grid>
</Window>
I run this code for the test but I got an error like this:
I checked "isEnabled" property for the button to true several times but I couldn't save it.
if someone help me to fix this, I'd be very appreciated.
thanks,
c00012