我创建了一个WPF应用程序.它在桌面上完全正常,但是当应用程序在触摸屏上运行时它会崩溃.我已经关闭了触摸屏流程,应用程序运行完全正常.我想知道有没有人找到一个"更好"的解决方案,而不是禁用触摸屏过程,因为这不适用于微软表面或Windows平板电脑.
我目前正在使用.Net 4.5
我有一个简单的linq lambda语句
Interactions = new BindableCollection<InteractionDTO>(ctx.Interactions.Where(x => x.ActivityDate > DateTime.Today)
.Select(x => new InteractionDTO
{
Id = x.Id,
ActivityDate = x.ActivityDate,
subject = x.Subject,
ClientNames = x.Attendees.Count == 1 ? x.Attendees.FirstOrDefault().Person.CorrespondenceName :
x.Attendees.FirstOrDefault().Person.CorrespondenceName : "Multiple attendees"
}));
Run Code Online (Sandbox Code Playgroud)
这将给我第一个客户名称,我试图让它出现前2名与会者后跟点.我试过这个
ClientNames = x.Attendees.Count == 1 ?
x.Attendees.FirstOrDefault().Person.CorrespondenceName :
x.Attendees.FirstOrDefault().Person.CorrespondenceName +
x.Attendees.Skip(1).FirstOrDefault().Person.CorrespondenceName + " ..."
Run Code Online (Sandbox Code Playgroud)
但我得到这个错误:
只有LINQ to Entities中的排序输入才支持'Skip'方法.必须在方法'Skip'之前调用'OrderBy'方法.
我正在尝试通过拖放功能上传文件.我成功地完成了UI工作,但是我无法访问在后端丢弃的对象.如果我在代码后面做的话,我能够成功地抓住对象,但我正在尝试采用MVVM方法.
AttachmentView.xaml
Cal:Message.Attach="[Drop] = [SaveFile($eventArgs)]"
Run Code Online (Sandbox Code Playgroud)
AttachmentViewModel.cs
public virtual async void SaveFile(DragEventArgs e)
{
var fileStream = new FileStream([File name goes here], FileMode.Open, FileAccess.Read);
}
Run Code Online (Sandbox Code Playgroud)
我试过EventArgs,我找不到文件对象属性.测试代码时,DragEventArgs为null.
代码背后的工作解决方案
AttachmentView.xaml.cs
private void ImagePanel_Drop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
// Note that you can have more than one file.
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
// Assuming you have one file that you care about, pass it off to whatever
// handling code you have defined.
Upload(files);
}
}
Run Code Online (Sandbox Code Playgroud) 如果我的静态字典中有重复的键,我希望有一个错误提升来阻止构建.
我目前的词典如下
public static readonly Dictionary<string, string> Fruits = new Dictionary<string, string>
{
{"Sobeys", "Apples"},
{"NoFrills", "Oranges"}
}
Run Code Online (Sandbox Code Playgroud)
但是,让我们说有人不小心将Sobeys改为Nofrills,我想提出一个编译错误,以防止在重复密钥解决之前完成任何事情.请问有可能吗?如果是这样我会怎么做?
public static readonly Dictionary<string, string> Fruits = new Dictionary<string, string>
{
{"NoFrills", "Apples"},
{"NoFrills", "Oranges"}
}
Run Code Online (Sandbox Code Playgroud) 目前我有一个网格,我正在尝试使用具有验证规则的单元格.为了验证它,我需要行的最小值和最大值.
验证类:
public decimal Max { get; set; }
public decimal Min { get; set; }
public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo)
{
var test = i < Min;
var test2 = i > Max;
if (test || test2)
return new ValidationResult(false, String.Format("Fee out of range Min: ${0} Max: ${1}", Min, Max));
else
return new ValidationResult(true, null);
}
Run Code Online (Sandbox Code Playgroud)
用户控制:
<telerik:RadGridView SelectedItem ="{Binding SelectedScript}"
ItemsSource="{Binding ScheduleScripts}">
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn
DataMemberBinding="{Binding Amount}" Header="Amount"
CellTemplate="{StaticResource AmountDataTemplate}"
CellEditTemplate="{StaticResource AmountDataTemplate}"/>
<telerik:GridViewComboBoxColumn
Header="Fee Type"
Style="{StaticResource FeeTypeScriptStyle}" …Run Code Online (Sandbox Code Playgroud) 我有一个 JSON 对象并尝试向我的 API 端点发出发布请求。
在我的列表控制器中,我有以下功能
[HttpPost]
public async Task<IActionResult> Import(GetImportInput input)
{
return StatusCode(200);
}
Run Code Online (Sandbox Code Playgroud)
获取导入输入.cs
public string Name {get; set;}
Run Code Online (Sandbox Code Playgroud)
邮递员详细信息:
ContentType = application/json
Body = {
"name" : "Rabbit"
}
Run Code Online (Sandbox Code Playgroud)
当我在 Import 方法中放置断点时,断点命中,但参数输入没有 value Rabbit。我可以问一下如何正确地让我的邮递员发送正文,以便我的控制器方法能够接收它。
标题选项卡
您好如何将支架格式的负值转换为double.目前我有这个.
Payment.Text = Calc_Payment().ToString("#,##0.00;(#,##0.00)");
Run Code Online (Sandbox Code Playgroud)
这会将付款转换为Bracket格式但我想反过来.括号格式的字符串为Double.如果有人可以帮忙请.
当我尝试将任何文件添加到我的项目时,我收到此错误:
名为 azazaz.cs 的文件或文件夹已存在。
请为您要添加的项目指定一个唯一名称,或先删除现有项目。
Visual Studio 最近没有更新。问题只出现在这一个项目中。它在其他计算机上正常工作。
到目前为止我尝试过的:
我尝试了许多不同的名称,检查了隐藏文件,并检查了文件夹位置。
按照 AbhishekP 的建议,删除了存储库并再次下载(通过 GitHub)。
按照 Srikanth 的建议,删除了“AppData\Local”文件夹中的“ComponentModelCache”文件夹。
检查了错误消息中文件名的“.csproj”文件夹,但它不存在。
我真的无法重新开始并创建一个新项目。
目前我的通知文档有一个 events 属性,它是一个事件数组。每个事件都有一个状态和日期。查询通知时,需要检查顶部状态是否打开。
打开最近事件状态的有效对象 -
{
"subject" : "Hello there",
"events" : [
{
"status" : "opened",
"date" : 2020-01-02 17:35:31.229Z
},
{
"status" : "clicked",
"date" : 2020-01-01 17:35:31.229Z
},
]
}
Run Code Online (Sandbox Code Playgroud)
无效对象,其状态不是最新的
{
"subject" : "Hello there",
"events" : [
{
"status" : "opened",
"date" : 2020-01-01 17:35:31.229Z
},
{
"status" : "clicked",
"date" : 2020-01-02 17:35:31.229Z
},
]
}
Run Code Online (Sandbox Code Playgroud)
目前,我有一个查询可以检查是否有任何事件的状态已打开,但我不确定如何仅查询前 1 个事件并按嵌套查询的日期排序。任何帮助将不胜感激。
var filter = Builders<Notification>.Filter.Empty;
filter &= Builders<Notification>.Filter.Regex("events.event", new BsonRegularExpression(searchString, "i"));
var results = …Run Code Online (Sandbox Code Playgroud) 目前我的代码变得非常重复.我必须在整个软件中反复提高繁忙指标.
这三个动作是
1. Raise Busy Indicator
2. Do the actions
3. Turn Off Busy Indicator
Run Code Online (Sandbox Code Playgroud)
例
public async void OpenAttachment()
{
Events.PublishOnUIThread(new BusyEvent { IsBusy = true });
await Task.Run(() =>
{
try
{
if (SelectedAttachment == null)
{
return;
}
var tempFile = string.Format(
"{0}\\{1}.{2}", Path.GetTempPath(), SelectedAttachment.FileName, SelectedAttachment.FileExtension);
System.IO.File.WriteAllBytes(tempFile, UnitOfWork.FileRepository.GetFileBytes(SelectedAttachment.Id));
Process.Start(tempFile);
}
catch (Exception ex)
{
Notification.Error("Person - Opening attachment", "File couldn't open, please close last file instance.");
}
});
Events.PublishOnUIThread(new BusyEvent { IsBusy = false });
}
Run Code Online (Sandbox Code Playgroud)
我正在寻找一种方法,这样它就可以执行繁忙的指示器,而不必每次都重复它. …
c# ×10
wpf ×2
asp.net-core ×1
caliburn ×1
linq ×1
mongodb ×1
mvvm ×1
postman ×1
telerik-grid ×1