[英]how to do I Silverlight read-only edit control, which I can cut and paste from?
I have a master-detail view, which I created in Silverlight 2. So, I'm not using the new master-detail stuff available in SL3. 我有一个在Silverlight 2中创建的主从视图。因此,我没有使用SL3中提供的新的主从视图。
So basically you have a grid at the top, and at the bottom you have the details for whatever item you select in the grid appearing in a panel. 因此,基本上,您在顶部有一个网格,在底部有您在面板中显示的网格中选择的任何项目的详细信息。
I did not want the user to be able to accidentally change the values in the fields, so I went with labels. 我不希望用户能够意外更改字段中的值,因此我选择了标签。
the user asked for cut and paste :) Because I could not get the focus of that label, I implemented a non standard cut and paste solution by having the user right click in the label, and it puts it on the clipboard. 用户要求剪切和粘贴:)因为无法获取该标签的焦点,所以我通过让用户右键单击标签并将其放置在剪贴板上来实现了非标准的剪切和粘贴解决方案。 The user then can do Ctrl+V to paste it somewhere else or in any other windows app. 然后,用户可以执行Ctrl + V将其粘贴到其他位置或任何其他Windows应用程序中。
However, now there are some users saying they need to be able to select a part of the item in the label, say the first 3 characters or the last 2 using the mouse or keyboard. 但是,现在有一些用户说他们需要能够选择标签中项目的一部分,例如使用鼠标或键盘的前3个字符或后2个字符。 So, it seems like the label needs to be replaced with an textbox control. 因此,似乎标签需要替换为文本框控件。
The problem doing this seems to be that if I set the textbox to readonly I cannot cut and paste from it. 这样做的问题似乎是,如果我将文本框设置为只读,则无法从中剪切和粘贴。 So, sure it's a textbox, and you cannot edit it, but you cannot copy/select from it either. 因此,请确保它是一个文本框,并且您不能对其进行编辑,但是也不能从中复制/选择它。
Is there another way to do this? 还有另一种方法吗?
thanks for any help you can provide, 感谢您的任何帮助,您可以提供,
Sincerely, J__ 真诚的,J__
TextBox should be fine. TextBox应该没问题。 I can't speak for Silverlight 2, and maybe there's an issue with SL2 and TextBox, but I just built a sample Silverlight 3 app, added a TextBox, and set Text="some text" and IsReadOnly="True". 我不能说Silverlight 2,也许SL2和TextBox存在问题,但是我只是构建了一个示例Silverlight 3应用程序,添加了TextBox,并设置了Text =“ some text”和IsReadOnly =“ True”。 I'm able to select any portion of the text (via mouse), and ctrl-c it to put it on the clipboard. 我可以选择文本的任何部分(通过鼠标),然后按ctrl-c将其放在剪贴板上。
Here's the (very simple) xaml I set up, with no code-behind. 这是我设置的(非常简单的)xaml,没有任何代码隐藏。 I'm able to select any portion of the text and copy it to the clipboard: 我可以选择文本的任何部分并将其复制到剪贴板:
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="layouttest.MainPage"
Width="640" Height="480">
<Grid x:Name="LayoutRoot" Background="White">
<TextBox Width="200" Height="30" Text="See if you can copy this"
TextWrapping="Wrap" IsReadOnly="True" />
</Grid>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.