我用CellEditingTemplate写了一个DataGrid的usercontrol.此编辑模板的DataTemplate是一个TextBox,光标将通过三次单击进入文本框,如果我想通过双击或单击将光标设置在文本框上,我该怎么办?
这是我的代码:
<Window x:Class="MultiLineEditDataGrid.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:MultiLineEditDataGrid"
Title="MainWindow" Height="350" Width="525">
<Grid DataContext="{Binding Source={x:Static Application.Current}, Path=CompanyManager}">
<Grid.RowDefinitions>
<RowDefinition Height="270"/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<DataGrid ItemsSource="{Binding Companies}" CanUserAddRows="False" AutoGenerateColumns="False">
<DataGrid.Resources>
<DataTemplate x:Key="cellTemplate">
<TextBlock Text="{Binding Description}"/>
</DataTemplate>
<DataTemplate x:Key="cellEditingTemplate">
<local:MultiLineTextBox Text="{Binding Description}"/>
</DataTemplate>
</DataGrid.Resources>
<DataGrid.Columns>
<DataGridTextColumn Header="Company" Binding="{Binding Name}"/>
<DataGridTemplateColumn Header="Description"
CellTemplate="{StaticResource cellTemplate}"
CellEditingTemplate="{StaticResource cellEditingTemplate}"/>
</DataGrid.Columns>
</DataGrid>
<Button Grid.Row="1" Content="Add" Command="{Binding AddCommand}"/>
</Grid>
Run Code Online (Sandbox Code Playgroud)
MultiLineTextBox是我从文本框继承的TextBox,并重写OnKeyDown方法.
MultiLineTextBox的代码:
public class MultiLineTextBox : TextBox
{
/// <summary>
/// On Key Down.
/// </summary>
/// <param name="e"></param>
protected override …
Run Code Online (Sandbox Code Playgroud) 很长一段时间以来,我一直在寻找.NET中的一个类,它具有使得操作系统认为在特定位置存在文件(或目录,或两者等)的功能 - 但所有钩子都是传递给代码中的函数(或事件?).
例:
如果我浏览到"x:\ fake_directory \",我会在那里看到一个文件,"fake_file.txt".如果我双击该文件,Notepad.exe将启动,文件内容将显示"Hello World"."Hello World"将来自我的c#代码.
我希望班级可以做的例子(也许这会更好地解释):
VirtualFile.Register("c:\my_file.txt",
delegate { return Encoding.Ascii.GetBytes("Hello World"); });
Run Code Online (Sandbox Code Playgroud)
当然,这是我正在寻找的简化版本......但希望你能得到这个想法.
这是100%需要的原因是使用遗留代码或专有(和非常旧的遗留垃圾)系统,这些系统需要读取和写入文件系统进行通信.
我想将键值传递给php页面.
在php页面,我将通过匹配开始读取值ajaxcallid
.
但它不起作用.
它必须使用我传递的语法/方式导致错误.
parse error
invalid json: ajax call id is missing
Run Code Online (Sandbox Code Playgroud)
的JavaScript/AJAX:
var person = {
"Address" : "123 Anywhere St.",
"City" : "Springfield",
"PostalCode" : 99999
};
alert(person);
person= JSON.stringify(person);
alert(person);
$.ajax({
url: 'ROOT_URL/admin/ajaxtest.php',
type: "POST",
dataType: 'json',
data: {ajaxcallid: '26', jsarr: person},
timeout: 5000,
success: function(output) {
alert(output.Address);
},
});
Run Code Online (Sandbox Code Playgroud)
PHP:
<?php
if (isset($_REQUEST['ajaxcallid']))
{
if($_REQUEST['ajaxcallid']==26)
{
//example, I want to read value of person.Address, person.City,
//person.PostalCode
//what is the easiest way
$phparr= json_decode($_REQUEST['jsarr']); …
Run Code Online (Sandbox Code Playgroud) 我需要facebook像按钮没有计数信息.我尝试了50px的宽度.但当有人"喜欢"这个页面时,"你喜欢它"并扭曲用户界面.
我需要像没有国家的形象.
谢谢Suren
我有url连接,通常工作正常
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request
delegate:delegate];
Run Code Online (Sandbox Code Playgroud)
但是当我创建一个模态窗口时,没有请求收到响应:
[NSApp runModalForWindow:window];
Run Code Online (Sandbox Code Playgroud)
如果我评论这一行,从而创建一个"标准"窗口,一切正常.
我尝试从NSURLConnectionDelegate实现所有方法,而不是调用它们中的一个.
我怀疑这是关于'run loops'的事情,但是在这方面没什么经验.有没有人有这方面的经验?
谢谢
Bitmap bmp = intent.getExtras().get("data");
int size = bmp.getRowBytes() * bmp.getHeight();
ByteBuffer b = ByteBuffer.allocate(size);
bmp.copyPixelsToBuffer(b);
byte[] bytes = new byte[size];
try {
b.get(bytes, 0, bytes.length);
} catch (BufferUnderflowException e) {
// always happens
}
// do something with byte[]
Run Code Online (Sandbox Code Playgroud)
当我在调用copyPixelsToBuffer
字节后查看缓冲区全部为0 ...从摄像机返回的位图是不可变的......但这应该无关紧要,因为它正在进行复制.
这段代码有什么问题?
有:
f = open(...)
r = re.compile(...)
Run Code Online (Sandbox Code Playgroud)
需要:
找一个大文件中第一个匹配正则表达式的位置(开始和结束)?
(从current_pos=...
) 开始
我怎样才能做到这一点?
我想要这个功能:
def find_first_regex_in_file(f, regexp, start_pos=0):
f.seek(start_pos)
.... (searching f for regexp starting from start_pos) HOW?
return [match_start, match_end]
Run Code Online (Sandbox Code Playgroud)
文件'f'预计会很大.
假设我们有一个Person
包含3列的表:
PersonId
类型int
.(首要的关键)Name
类型string
.GenderId
类型int
(外键引用Gender
表).该Gender
表由2列组成:
GenderId
类型int
.Name
类型string
.我的问题是:是否值得实施该Gender
表?或者它会导致性能下降?处理这个问题的最佳方法是什么?
我必须在我的UI中填充一个下拉控件,其中包含一系列固定性别(女性和男性).
是否只有我可以使用php的美国时区列表?我使用PHP的时区名称,如America/Anchorage,php在这里列出时区:
http://us.php.net/manual/en/timezones.others.php
我想在下拉列表中显示它们供用户选择,但我只需要美国的那些,我不想展示一堆在美国之外.
您使用什么经验法则决定使用node_load()
或只是直接写db_query()
?
在我正在查看的情况下,我需要获取一些节点数据并解析两个nodereference字段上的数据.所以这将是3次调用node_load()
.在某些时候,使用Joins直接构造查询会更有效吗?
这是用于自包含的模块,不会在其他任何地方分发或使用,所以我不相信我需要担心颠覆节点修改挂钩(或者我?).
编辑:
更多地考虑我的问题,node_load()
只有当你有一个节点要抓取时才真正适用(然后可能会深入研究如我的例子中的节点参考).但是一旦你需要根据某些标准返回多个节点,你几乎被迫使用了db_query
吗?Drupal是否有任何用于编写此类查询的抽象API?