我正在开发一个使用语义缩放的Windows 8 metro应用程序,方法如下:
放大视图包含一个ListView
复杂的控件,允许用户交互(通过使用TextBox和Button控件),因此这个ListView具有IsItemClickEnabled="False"
.用户必须手动触发缩小视图.
缩小视图包含另一个ListView
显示简单列表,该列表显示放大视图中控件的某些状态信息.ItemsSource
此ListView 的属性使用在视图处于活动状态时创建的普通对象进行动态填充.这个ListView有IsItemClickEnabled="True"
.
我想要什么:
当用户点击或点击缩小视图中的项目时,应该激活放大的视图,并且应该使与所单击的项目匹配的控件可见(放大的ListView允许滚动,因此可以隐藏控件).只要在SelectionChanged
单击项目时触发事件,我就知道如何执行此操作.
会发生什么:
当用户点击或点击缩小视图中的项目时,放大视图会自动激活,不会SelectionChanged
触发任何事件.但是,使用右键单击或Ctrl +单击时,它可以正常工作.
所以,我的问题是:
有没有办法让ListView触发SelectionChanged
项目点击或左键单击事件,除了右键单击和Ctrl +单击?如果没有,我如何检测点击或左键点击?
非常感谢你!
我正在为自己即将进行的测试做一些工作,发现这个我无法理解的问题.
int[] div = new int[]{2,3,5};
IEnumerable<int>seq = new int[]{10,15,20,25,30};
for(int i = 0; i<div.Length;i++){
int y = div[i];
seq = seq.Where(s => s%y == 0)
}
seq = seq.ToList();
Run Code Online (Sandbox Code Playgroud)
我认为结果序列将是10 15 20 25 30,但实际答案是30.
我尝试自己运行代码,我发现当代码运行for循环时,序列不会重置为原始序列,但它会保留前一个div [i]创建的序列.
例如,当i = 0时,div [0]为2,因此seq选择10,20和30.
当代码进行到i = 1且div [1] = 3时,它用于计算部分的序列仍然是{10,20,30}而不是{10,15,20,25,30}.
有人可以解释原因吗?
当我像这样移动到for循环的外部时,
int[] div = new int[]{2,3,5};
IEnumerable<int>seq = new int[]{10,15,20,25,30};
int y;
for(int i = 0; i<div.Length;i++){
y = div[i];
seq = seq.Where(s => s%y == 0)
}
seq = seq.ToList();
Run Code Online (Sandbox Code Playgroud)
它给出了我期待的答案. …
我怎么能从我的json中获取逗号:我将此作为输出json
{Floor_Id:"1094",Booth_Count:12},{Floor_Id:"1095",Booth_Count:10},
Run Code Online (Sandbox Code Playgroud)
这是我的C#代码:
StringBuilder json_result = new StringBuilder();
List<XElement> industries = ExpoHallXML.Descendants("industry").ToList();
if (industries != null && industries.Count > 0)
{
foreach (XElement industry in industries)
{
foreach (XElement floor in industry.Descendants("floor"))
{
if (floor.Attribute("id").Value != "0")
{
json_result.Append("{");
json_result.Append("Floor_Id:" + cmh.json_str(floor.Attribute("id").Value) + ",");
int booth_count = 0;
foreach (XElement page in floor.Descendants("page"))
{
booth_count = page.Descendants("booth").Count();
json_result.Append("Booth_Count:" + booth_count +"},");
}
}
}
}
}
return json_result.ToString();
Run Code Online (Sandbox Code Playgroud)
请帮忙!谢谢
我正在执行一些测试,并且我有一个包含表单错误的值列表:
12.7 ± 0.3
14.2 ± 0.1
70.8 ± 0.5
Run Code Online (Sandbox Code Playgroud)
我需要将标准偏差与值保持一致,因为我稍后需要将其用于各种计算.
目前我正在使用
List<KeyValuePair<double, double>>
Run Code Online (Sandbox Code Playgroud)
但有更好的解决方案吗?
为了与线程,代表和后台工作者一起玩,我正在整理一些小应用程序,我对其中一个有点麻烦.我有一个Windows表单,带有文本框,按钮和richttext.当我按下按钮时,文本框中的文本被用作实例化类的参数,如下所示:
public partial class Form1 : Form
{
private BackgroundWorker backgroundWorker;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
backgroundWorker = new BackgroundWorker();
backgroundWorker.DoWork += new DoWorkEventHandler(worker_DoWork);
backgroundWorker.RunWorkerAsync();
}
void worker_DoWork(object sender, DoWorkEventArgs e)
{
new Thread((ThreadStart)delegate()
{
this.BeginInvoke((ThreadStart)delegate()
{
foreach (string line in textBox1.Lines)
{
Dig digger = new Dig(line, textBox1.Text);
digger.DomainChecked += new Dig.DomainCheckedHandler(OnUpdateTicker);
string response = digger.GetAllInfo();
richTextBox1.AppendText(response);
Application.DoEvents();
}
});
}).Start();
}
void OnUpdateTicker(string msg)
{
new Thread((ThreadStart)delegate()
{
this.BeginInvoke((ThreadStart)delegate()
{
label4.Text …
Run Code Online (Sandbox Code Playgroud) 我想在表单中添加一个通用的"取消"按钮.通用我的意思是在具有不同于英语语言环境的系统上,它将显示本地化的"取消"字符串.怎么做到这一点?
我正在编写一个脚本来帮助我将一组文本文件转换为markdown.这个脚本所做的一件事就是将斜体和标题格式应用于图形标题,这些标题是以一些空格和单词"图"开头的行.这是我的代码:
text = Regex.Replace(text, "^ +(Figure.*)$", "##### _$1_", RegexOptions.Multiline);
Run Code Online (Sandbox Code Playgroud)
如果我用它来转换这个文本:
A Foobar is cool stuff, as we can see in Figure 1.1:
Figure 1.1 This is a Foobar
More text here.
Run Code Online (Sandbox Code Playgroud)
...然后我明白了:
A Foobar is cool stuff, as we can see in Figure 1.1:
##### _Figure 1.1 This is a Foobar _
More text here.
Run Code Online (Sandbox Code Playgroud)
...除了一个小细节外,我想要的是:在LinqPad输出窗口的最后一个下划线字符之前添加了一个空格.我不知道它来自何处,因为它不存在于原始文本中(在"Foobar"之后有一个CRLF序列).我的正则表达式或我如何使用它有什么问题?
编辑:完整的可执行程序演示问题:
using System;
using System.Text.RegularExpressions;
class Test
{
static void Main()
{
string text =
@"A Foobar is cool stuff, as we can …
Run Code Online (Sandbox Code Playgroud)