Articles in this section
Category / Section

How to display null value in Silverlight CurrencyTextBox?

1 min read

To display a null value when the databound value of the editor is null, set the UseNullOption property to True.

UseNullOption:

The UseNullOption is a Boolean property of the Editors like CurrencyTextBox, IntegerTextBox, DoubleTextBox, PercentTextBox that is used to display a null value when the databound value is null according to its values such as True or False.

When the value of UseNullOption is set to True, it is used to display a databound null Value, instead of the default value.

When the value of UseNullOption is set to False, it disables the Null value and display the default value zero for the control.

Here is an example that describes the use of a UseNullOption property in IntegerTextBox. Refer to the following code example.

XAML

// sets the UseNulloption true for an IntegerTextBox
<UserControl x:Class="NewEditorApplication.MainPage"
    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:sync="http://schemas.syncfusion.com/silverlight"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400" >
    <Grid x:Name="LayoutRoot" Background="Black">
          <sync:IntegerTextBox Name="integer1" UseNullOption="True" Value="{Binding MyValue}" Width="250" Height="50" />
    </Grid>
</UserControl>

 

C#

// the property of the Binding value named MyValue
namespace NewEditorApplication
{
    public partial class MainPage : UserControl
    {
            private string Myvar;
            public string MyValue
            {
                get { return Myvar; }
                set {  Myvar = value; }
            }
        public MainPage()
        {
            InitializeComponent();
            this.DataContext = this;
            MyValue = null;
        }
    }
}

 

The following screenshot displays the Null value when the UseNullOption property is set to True for an IntegerTextBox.

XAML

// sets the UseNulloption false for an IntegerTextBox
<UserControl x:Class="NewEditorApplication.MainPage"
    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:sync="http://schemas.syncfusion.com/silverlight"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">
    <Grid x:Name="LayoutRoot" Background="Black">
          <sync:IntegerTextBox Name="integer1" UseNullOption="False" Value="{Binding MyValue}" Height="50" />
    </Grid>
</UserControl>

 

C#

// the property for Binding value named MyValue 
namespace NewEditorApplication
{
    public partial class MainPage : UserControl
    {
            private string Myvar;
            public string MyValue
            {
              get { return Myvar;}
              set {  Myvar = value; }
            }
          public MainPage()
          {
            InitializeComponent();
            this.DataContext = this;
            MyValue = null;
          }
    }
}

 

The following screenshot displays the default value Zero when the UseNullOption property is set to False for an IntegerTextBox

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied