【问题标题】:xamdatetimeeditor set default current time and datexamdatetimeeditor 设置默认当前时间和日期
【发布时间】:2014-04-24 09:34:43
【问题描述】:

如何在 xamdatetimeeditor 中设置默认的当前时间和日期而不是默认的空白?

我下面的代码不会显示当前日期和时间。
在从 xamDateTimeEditor 下拉菜单中选择日期时间之前,它将为空白。

在 xaml 中

<igEditors:XamDateTimeEditor 
        Grid.Row="12" Grid.Column="2" x:Name="Date" 
        Visibility="{Binding datetimeVisible, Converter={StaticResource booleanToVisibility}}"
        Height="23" Validation.Error="Validation_Error" Mask="yyyy/mm/dd hh:mm:ss" 
        DropDownButtonDisplayMode="Always"  DisplayMode="IncludeBoth" 
        Value="{Binding DateInitial, UpdateSourceTrigger=PropertyChanged,
                        ValidatesOnDataErrors=true, NotifyOnValidationError=true}"
        Text ="{Binding DateSelected, UpdateSourceTrigger=PropertyChanged,
                        ValidatesOnDataErrors=true, NotifyOnValidationError=true}">
    <igEditors:XamDateTimeEditor.ValueConstraint>
        <igEditors:ValueConstraint 
                MaxInclusive="{x:Static sys:DateTime.Now}" ValidateAsType="DateTime" />
    </igEditors:XamDateTimeEditor.ValueConstraint>
</igEditors:XamDateTimeEditor>

在后面的代码中

public string Error
{
    get { throw new NotImplementedException(); }
}

public string this[string columnName]
{
    get
    {
        string result = null;
        if (columnName == "DateSelected")
        {
            if (string.IsNullOrEmpty(DateSelected))
            {
                result = "Please select date";
            }
        }
        return result;
    }
}

public DateTime DateInitial
{
    get { return this.dateInitial; }
    set
    {
        this.dateInitial = value;

        this.NotifyPropertyChanged("Date");
        Trace.WriteLine("dateInitial !!!! " + dateInitial);
    }
}

【问题讨论】:

    标签: wpf xaml infragistics


    【解决方案1】:

    我想通了: 将 NullText 添加到 &lt;igEditors:XamDateTimeEditor

    NullText="{Binding Source={x:Static sys:DateTime.Now}, StringFormat='{}{0:yyyy/MM/dd H:mm:ss}'}"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-04-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-06
      • 2018-07-25
      • 2014-07-02
      相关资源
      最近更新 更多