- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我已经完成了从 TextBox 到 Property 的绑定(bind)。如果用户将日期值写入 TextBox,它应该会自动更正。 f.e.: 20.01.10 -> 20.01.2010
更正在属性设置 block 中完成:
public String DateOfBirth
{
get
{
if (patient.DateOfBirth != DateTime.MinValue)
return patient.DateOfBirth.ToString("dd.MM.yyyy");
else
return patient.BirthdayString;
}
set
{
string dateParsed = ValidateDatePart(value, false, true);
DateTime date = new DateTime();
DateTime.TryParse(dateParsed, out date);
patient.DateOfBirth = date;
patient.BirthdayString = dateParsed;
base.OnPropertyChanged("DateOfBirth");
}
}
patient.DateOfBirth
和 patient.BirthdayString
是我应用程序数据模型中的值。需要将生日作为字符串返回,因为用户应该能够输入生日的一部分,例如如果生日不完全为人所知,例如“12.1967”。我的问题是,如果用户输入类似“20.01.10”的日期,该日期会在属性中得到更正,但更正后的日期 (“20.01.2010”) 未设置到 TextBox。 TextBox 仍包含“20.01”。有人知道如何更新 TextBox 吗?绑定(bind)模式默认为TwoWay。
这是文本框的 XAML:
<TextBox Validation.ErrorTemplate="{StaticResource errorTemplate}" Style="{StaticResource NotEmptyTextBox}">
<Binding Path="OrderVM.Patient.DateOfBirth" ValidatesOnDataErrors="True" ValidatesOnExceptions="True" />
</TextBox>
最佳答案
试试看
Text="{Binding Path=Name, UpdateSourceTrigger=PropertyChanged}"
关于c# - 如何在更正绑定(bind)属性后立即更新 TextBox?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3456641/
这个问题在这里已经有了答案: How to automatically select all text on focus in WPF TextBox? (33 个答案) How to select
我在我的项目中使用了以下模板:
我有一个非常奇怪的问题。我有多个用于用户名/密码的文本框,每个用户/密码组旁边都有一个复选框。当用户单击 CheckBox 时,如果他选中它,它旁边的用户名和密码 TextBox 将被启用,焦点将设置
我有两个带有这样的日期选择器的文本框。 $(function () { $('#value_date').datetimepicker({ format: 'MM/DD/YY
我检查了大约 60 个国家/地区的邮政编码。用户输入邮政编码,根据该国家/地区的规则进行检查。美国是个异常(exception),我可以根据已输入的其他街道地址信息自动填写值。在某些方面,它基本上是一
我们的应用程序启动几个后台进程并将它们的输出放入 TextBoxes - 每个在 TabControl 中的一个单独的 TabItem。我希望 TextBoxes 自动滚动以显示最后一个输出行,因此在
TextBlock 元素很好地处理了 LineHeight,允许文本完全显示,而无需剪切。但是,我想将其更改为 TextBox 以方便编辑文本,这就是我的麻烦开始的地方。 TextBlock 显示如下
我正在尝试“帮助”用户表单上文本输入框的用户输入百分比。 截至目前,我的输入框将任何输入转换为百分比形式。这意味着键入“6”会将值转换为 600%。如下所示 databaseViewer 是输入框从中
我有一个带有 RichEditBox 的 Windows 应用商店应用程序(编辑)和一个 Grid (边注)。 我需要始终匹配两个元素的垂直滚动位置。这样做的目的是允许用户在文档的页边空白处添加注释。
我有一个问题。下面的代码用于通过 .append() 和 .remove() 动态添加和删除文本框。我希望占位符为 textbox 的文本框中的所有数据都会内爆,并放置在我设置的名称为 textbox
我有一个文本框,其 Text 属性具有 TwoWay MultiBinding,UpdateSourceTrigger 设置为 属性已更改。第一个 Binding 是一个依赖属性 (Value),它具
它们之间有什么区别吗?谢谢 TextBox.Clear(); TextBox.Text = string.Empty; 最佳答案 在实践中:不。在内部,有。两者都以完全不同的方式清除文本。 我不敢告
这两种方法有什么区别? 一个比另一个更有效率吗? 我在想 AppendText() 可能使用类似于 StringBuilder 的方法,即它使用自己的缓存而不是每次都创建和附加一个新字符串,是这样吗?
我有一个文本框来显示一个很长的 Base64 字符串。 TextBox.Multline = true 和 TextBox.WordWrap = true。 此问题是由文本框本身的自动字边界检测引起的
在 this document在描述 Windows 10 UWP 应用程序的生命周期时,它指出: Users now expect your app to remember its state as
我需要检查如果我的 TextBox (txtmoney) 为空或等于 0,则不允许按 0 键键盘或数字 0。 我该怎么做? 最佳答案 Before implementing please refer
我有一个显示一些 TextBoxes 的 ListView。对于每个 TextBox,我都会捕获一个 SelectionChanged 事件。 我的 XAML 文件看起来像这样:
当我单击(或双击)Access 表单的文本框时,我需要选择其中的所有文本。我尝试了以下代码,但没有成功: Me.txt_CompraPreco.SelStart = 0 Me.txt_CompraPr
我有一个 ListView(在更新面板中)绑定(bind)到一个 ObjectDataSource(连接到一个 NHibernate 对象)并且在 EditItemTemplate 我使用 Text=
我正在尝试使用 D3 绘制多条交互式线条。单击每一行时,应根据当前鼠标坐标显示一个 float 文本框,并等待输入更新行坐标。更改文本框后,该行应自动更新,文本框应消失。有人可以看看我的代码并找出问题
我是一名优秀的程序员,十分优秀!