سؤال

أحاول رفع أخطاء التحقق من الصحة:1.عندما يقوم المستخدم بإدخال لنا مشروع تجديد نظم الإدارة التي لا عدد ، سيلفرلايت يعرض خطأ عند مغادرة الميدان 2.ومع ذلك إذا كان في نفس المجال أضع رقم سلبي لا يتم عرض خطأ على الرغم من أن هناك صريح النطاق المحدد
ماذا هل أنا بحاجة إلى تغيير ؟

كما مكافأة السؤال: ما أنا من المفترض أن تستخدم في XAML قراءة قيمة العرض(اسم = "اسمي لنا مشروع تجديد نظم الإدارة:" بدلا من أن تحدد صراحة شيء آخر

public class CalculatorParameters : INotifyPropertyChanged
{ 
      private double _usMsrp;

    public CalculatorParameters()
    { 
    }


    [Display(Name = "My Name is US MSRP:",
        Description = "The residual value is based on the US MSRP, even with Euro-Delivery")]
    [Range(0, 150000, ErrorMessage = "US MSRP must be a positive amount under $150,000")]
    public double UsMsrp
    {
        get { return _usMsrp; }
        set
        {
            _usMsrp = value;
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs("UsMsrp"));
        }
    } 

    #region INotifyPropertyChanged Members

    public event PropertyChangedEventHandler PropertyChanged;

    #endregion

}

و هنا XAML

 <UserControl x:Class="Silverlight.ConfigEnhanced.UcFinance"
       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:my="clr-namespace:Silverlight.ConfigEnhanced"
         xmlns:df="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.DataForm.Toolkit" 
                 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
       mc:Ignorable="d"
       d:DesignHeight="650" d:DesignWidth="500"  >
        <UserControl.Resources>
            <my:CalculatorParameters x:Key="descriptor"/>
        </UserControl.Resources>
        <df:DataForm x:Name="df1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" CurrentItem="{StaticResource descriptor}" CommandButtonsVisibility="None" AutoGenerateFields="False" >
            <df:DataForm.EditTemplate>
                <DataTemplate>
                    <Grid x:Name="LayoutRoot" Background="White">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="160"></RowDefinition>
                            <RowDefinition Height="20"></RowDefinition>
                            <RowDefinition Height="*"></RowDefinition>
                            <RowDefinition Height="270"></RowDefinition> 
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"></ColumnDefinition>
                            <ColumnDefinition Width="*"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <StackPanel Grid.Row="2" Grid.Column="0">
                            <TextBlock Text="Leasing"  HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold"  Margin="0,0,0,15" />
                            <df:DataField Label="Term in Months">
                                <TextBox   Name="txtBoxLeaseTermInMonths" Text="{Binding LeaseTermInMonths, Mode=TwoWay}" GotFocus="RecomputeLease"/>
                            </df:DataField>
                            <df:DataField Label="Down Payment">
                                <TextBox   Name="txtBoxLeaseDownPayment" Text="{Binding LeaseDownPayment, Mode=TwoWay}" GotFocus="RecomputeLease"/>
                            </df:DataField>
                            <df:DataField Label="Money Factor">
                                <TextBox   Name="txtBoxLeaseMoneyFactor" Text="{Binding MoneyFactor, Mode=TwoWay}" GotFocus="RecomputeLease"/>
                            </df:DataField>
                            <df:DataField Label="US MSRP">
                                <TextBox   Name="txtBoxLeaseUsMsrp" Text="{Binding UsMsrp, Mode=TwoWay}" GotFocus="RecomputeLease"/>
                            </df:DataField>
                      </StackPanel>
                    </Grid>
                </DataTemplate>
            </df:DataForm.EditTemplate>
        </df:DataForm>
    </UserControl>
هل كانت مفيدة؟
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top