Beta 10.7 of C#/XAML for HTML5 released
Posted: Fri Jan 13, 2017 6:20 pm
Dear CSHTML5 users,
We are pleased to inform you that the Beta 10.7 of CSHTML5 is available for download!
Download:
Here is what's new since Beta 10.6:
Many more new features to come... stay tuned!
You may also be interested to read:
- What's new in Beta 10.6
- What's new in Beta 10.5
- What's new in Beta 10.4
- What's new in Beta 10.3
- What's new in Beta 10.2
- What's new in Beta 10.1
-------------------------------------------------------------
Example of use of the TextBox validation feature:
-------------------------------------------------------------
The following example shows a form where the user must enter his/her name and age. Both fields are required, and they display an error message if they are invalid. The "OK" button becomes enabled only when both fields are valid.
XAML CODE:
C# CODE:
Notes about installation:
We hope you will enjoy this build!
If you find any issues, please post them on the forums or send an email to support@cshtml5.com
Thank you.
Regards,
JS-Support
We are pleased to inform you that the Beta 10.7 of CSHTML5 is available for download!
Download:
Here is what's new since Beta 10.6:
- Added support for TextBox validation, including Binding.ValidatesOnExceptions and Binding.NotifyOnValidationError (special thanks to Azzly for sponsoring this feature!)
- Improved support for importing TypeScript Definitions (still a work-in-progress feature: major improvements are expected in the coming weeks). For more info, please read: http://cshtml5.com/links/importing-typescript-definitions.aspx
- Added support for Popup.Placement and Popup.PlacementTarget
- Fixed an issue where programmatically unchecking a checkbox did not work properly
- Fixed exception when setting FrameworkElement.MaxWidth and MaxHeight
Many more new features to come... stay tuned!
You may also be interested to read:
- What's new in Beta 10.6
- What's new in Beta 10.5
- What's new in Beta 10.4
- What's new in Beta 10.3
- What's new in Beta 10.2
- What's new in Beta 10.1
-------------------------------------------------------------
Example of use of the TextBox validation feature:
-------------------------------------------------------------
The following example shows a form where the user must enter his/her name and age. Both fields are required, and they display an error message if they are invalid. The "OK" button becomes enabled only when both fields are valid.
XAML CODE:
Code: Select all
<Border x:Name="ValidationBorder">
<StackPanel Orientation="Vertical" Margin="15">
<StackPanel Orientation="Horizontal">
<TextBlock Text="Your First Name: "/>
<TextBox x:Name="NameTextBoxForValidation" Text="{Binding Name, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnExceptions=True}" BindingValidationError="ValidationBorder_BindingValidationError" HorizontalAlignment="Left" Margin="5,0,0,0" MinWidth="100"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<TextBlock Text="Your Age: "/>
<TextBox x:Name="AgeTextBoxForValidation" Text="{Binding Age, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnExceptions=True}" BindingValidationError="ValidationBorder_BindingValidationError" HorizontalAlignment="Left" Margin="5,0,0,0" MinWidth="40"/>
</StackPanel>
<Button x:Name="MyButtonForValidation" Content="OK" Click="MyButtonForValidation_Click" HorizontalAlignment="Left" Margin="0,10,0,0"/>
</StackPanel>
</Border>
C# CODE:
Code: Select all
public MainPage()
{
this.InitializeComponent();
// Set the DataContext:
Person person = new Person();
ValidationBorder.DataContext = person;
}
private void ValidationBorder_BindingValidationError(object sender, ValidationErrorEventArgs e)
{
// Enable or disable the "OK" button depending on whether there are any errors:
if (Validation.GetHasError(NameTextBoxForValidation) || Validation.GetHasError(AgeTextBoxForValidation))
{
MyButtonForValidation.IsEnabled = false;
MyButtonForValidation.Opacity = 0.4;
}
else
{
MyButtonForValidation.IsEnabled = true;
MyButtonForValidation.Opacity = 1.0;
}
}
private void MyButtonForValidation_Click(object sender, RoutedEventArgs e)
{
Person person = (Person)((Button)sender).DataContext;
string str = "Your first name is : " + person.Name + Environment.NewLine + "Your age is: " + person.Age + ".";
System.Windows.MessageBox.Show(str);
}
public class Person : System.ComponentModel.INotifyPropertyChanged
{
private string _name;
public string Name
{
get { return _name; }
set
{
if (string.IsNullOrWhiteSpace(value))
throw new Exception("The 'Name' field cannot be empty.");
_name = value;
RaisePropertyChanged("Name");
}
}
private int _age;
public int Age
{
get { return _age; }
set
{
if (value <= 0)
throw new Exception("The 'Age' field must be greater than 0. You must enter a valid age in order to continue.");
_age = value;
RaisePropertyChanged("Age");
}
}
private void RaisePropertyChanged(string propertyName)
{
PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
}
public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
}
Notes about installation:
- Before installing this update, it is recommended that you close all the open instances of Visual Studio.
- If for some reason you need to revert to the previous Beta, simply uninstall this one (from the Control Panel) and reinstall the previous Beta.
We hope you will enjoy this build!
If you find any issues, please post them on the forums or send an email to support@cshtml5.com
Thank you.
Regards,
JS-Support