[英]WPF Using textbox custom style causing not to be able to insert text to the textbox
[英]Insert text into WPF textbox before the old text
我如何在舊文本之前將文本插入WPF textbox
像old text
然后我添加文本new text old text
你也可以使用
textbox.Text="my new text" + textbox.Text;
要么
txtbox1.SelectionStart = 0;
txtbox1.SelectedText = "my new text";
我認為最簡單的方法是使用Binding Converter來獲取已更改的數據,並在將其分配給UI之前將其轉換為您想要的格式。
@ S3ddi9對於第二個選項,您可能需要這樣做:
txtbox1.SelectionStart = 0;
txtbox1.SelectionLength = 0; //this was missing
txtbox1.SelectedText = "my inserted text at top";
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.