wpf - xamdatetimeeditor 设置默认当前时间和日期

标签 wpf xaml infragistics

如何在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);
    }
}

最佳答案

我明白了: 将 NullText 添加到 <igEditors:XamDateTimeEditor

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

关于wpf - xamdatetimeeditor 设置默认当前时间和日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23265102/

相关文章:

c# - 如何在 C# 中使用内联 XAML 在代码隐藏中轻松创建自定义对象

c# - 显示 Silverlight 的 ComboBox 组 header

c# - Infragistics UltraGrid - 如何在滚动到达底部时添加行?

infragistics - 从底部到顶部显示基础设施UltraGrid行

c# - gridview 停止在 Javascript 中具有带有 IF 条件的母版页的所有页面上工作

.net - 启动时完全隐藏WPF窗口吗?

wpf - 寻找一些关于使用 MVVM 创建最佳实践单元测试的良好引用

c# - 在接口(interface)中传递方法

c# - 处理非常低的动画帧率

c# - Xaml C# 中 Windows 8 商店应用程序的游戏循环