我DataTemplate
在xaml文件中定义了我想通过C#代码访问的文件.任何人都可以告诉我如何访问它?我添加了一个新ResourceDictionary
文件,它的名字是Dictionary1.xaml.我有一个数据模板,如:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<DataTemplate x:Key="mytemplate">
<TextBlock Text="Name:" Background="Blue"/>
</DataTemplate>
</ResourceDictionary>
Run Code Online (Sandbox Code Playgroud)
不是我有一个ListBox
名为listBox1,我想将它分配给它的Itemtemplate
属性,但我不知道怎么办呢?
我有一项任务要做.我需要检索a tag
或href
特定的id
(id
基于用户输入).示例我有html
这样的
<manifest>
<item href="Text/Cover.xhtml" id="Cov" media-type="application/xhtml+xml" />
<item href="Text/Back.xhtml" id="Back" media-type="application/xhtml+xml" />
</manifest>
Run Code Online (Sandbox Code Playgroud)
我已经有了这个代码.请帮我.谢谢
HtmlAgilityPack.HtmlDocument document2 = new
HtmlAgilityPack.HtmlDocument();
document2.Load(@"C:\try.html");
HtmlNode[] nodes = document2.DocumentNode.SelectNodes("//manifest").ToArray();
foreach (HtmlNode item in nodes)
{
Console.WriteLine(item.InnerHtml);
}
Run Code Online (Sandbox Code Playgroud) 我试图通过缠绕在我头上的功能进行分区.这是一个我不明白的例子.
这是我的数据:
SALESORDERID ORDERDATE
43894 08/01/2001
43664 07/01/2001
43911 08/01/2001
43867 08/01/2001
43877 08/01/2001
44285 10/01/2001
44501 11/01/2001
43866 08/01/2001
43895 08/01/2001
43860 08/01/2001
Run Code Online (Sandbox Code Playgroud)
当我运行此查询时:
select Row_Number() over(partition by orderdate order by orderdate asc)
as Rownumber, salesorderid, orderdate
from test2
order by rownumber
Run Code Online (Sandbox Code Playgroud)
以下是我得到的结果:
ROWNUMBER SALESORDERID ORDERDATE
1 43664 07/01/2001
1 43911 08/01/2001
1 44109 09/01/2001
1 44483 11/01/2001
1 44285 10/01/2001
2 43867 08/01/2001
2 44501 11/01/2001
3 43895 08/01/2001
4 43894 08/01/2001
5 43877 08/01/2001
Run Code Online (Sandbox Code Playgroud)
有人可以向我解释这个问题.我并不是SQL的新手,但是我一直在苦苦挣扎,并且不能让我的头脑缠身.
我最近被一位同事问到:是否可以通过一个数组中的一个查询获取前五个元素和最后五个元素?
int[] someArray = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 };
Run Code Online (Sandbox Code Playgroud)
我尝试过的:
int[] someArray = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 };
var firstFiveResults = someArray.Take(5);
var lastFiveResults = someArray.Skip(someArray.Count() - 5).Take(5);
var result = firstFiveResults;
result = result.Concat(lastFiveResults);
Run Code Online (Sandbox Code Playgroud)
是否可以通过一个查询获取前五个元素和后五个元素?
所以我试图弄清楚如何生成一个关联数组,列出数组的元素,以及每个元素出现的次数,而不事先知道元素是什么.
举个例子,假设我有一系列动物: var animals = ['Rhino', 'Lion', 'Dog', 'Parrot', 'Parrot', 'Cat', 'Zebra', 'Rhino']
我想生成一个最终看起来像的对象:
{ 'Rhino': 2, 'Lion': 1, 'Dog': 1, 'Parrot': 2, 'Cat': 1, 'Zebra': 1 }
Run Code Online (Sandbox Code Playgroud)
如果我事先知道阵列中的动物是什么,我当然可以这样做:
var animalsCount = {};
var numberOfRhinos = animals.filter(function(animal) {
return animal == 'Rhino'
}).length;
animalsCount['Rhino'] = numberOfRhinos
Run Code Online (Sandbox Code Playgroud)
得到一个像我想要的对象.问题当然是根据动物的数量,这变得非常冗长和重复.同样,如果我不知道每种动物是什么,我就不能用这种方式创造物体.必须有一种方法可以在不知道这些信息的情况下做到这一点,但我被困住了.
我使用PHPExcel从数据库导出我的文件,但我的问题是当我下载我的Excel时,我的工作表的名称是默认的"工作表".我想将它设置为另一个名称,如"Hello world".
到目前为止,这是我的代码
require_once dirname(__FILE__) . '/Classes/PHPExcel.php';
$objPHPExcel = new PHPExcel();
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A1', '1')
->setCellValue('B1', '2')
->setCellValue('C1', '3')
->setCellValue('D1', '4')
->setCellValue('E1', '5')
->setCellValue('F1', '6')
->setCellValue('G1', '7')
->setCellValue('H1', '8')
->setCellValue('I1', '9')
->setCellValue('J1', '10');
$row = 2;
while($rowz = $result->fetch(PDO::FETCH_ASSOC)) {
$col = 0;
foreach($rowz as $key=>$value) {
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, $value);
$col++;
}
$row++;
}
Run Code Online (Sandbox Code Playgroud)
我如何为工作表设置新标题?谢谢!
我刚刚安装Visual Studio 2015
并刚刚创建了新ASP.NET Core Web Application
项目。当我运行该ASP.NET Core Web application
项目时,我遇到了以下异常(我只是Ctrl+F5
想在 Visual Studio 2015 中运行该项目):
似乎没有安装在 IIS 中托管 .NET Core 项目所需的 ASPNETCoreModule。尝试修复 Visual Studio 以更正问题。
如果我运行其他类型的项目,例如ASP.NET MVC
或ASP.NET Web API
,那么它们运行得很好。
已经安装了以下 SDK:
我的project.json
文件:
{
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.1",
"type": "platform"
},
"Microsoft.ApplicationInsights.AspNetCore": "1.0.0",
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.1",
"Microsoft.AspNetCore.Razor.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.AspNetCore.Routing": "1.0.1",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Logging": …
Run Code Online (Sandbox Code Playgroud) 我开发了一个使用ASP.NET Core Web API
和构建的Web应用程序Angular 4
.我的模块捆绑器是Web Pack 2
.
我想通过Facebook,Twitter,Google使我的应用程序可抓取或链接共享.url
当某些用户试图在Facebook上发布我的新闻时,必须是相同的.例如,Jon希望与http://myappl.com/#/hellopage
Facebook 共享页面 - 在Facebook上,然后Jon将此链接插入Facebook : http://myappl.com/#/hellopage
.
我已经看过这个没有标签帮助器的Angular Universal服务器端渲染教程,并希望进行服务器端渲染.因为我使用ASP.NET Core Web API
,我的Angular 4
应用程序没有任何.cshtml
视图,所以我无法从控制器发送数据ViewData["SpaHtml"]
从我的控制器查看:
ViewData["SpaHtml"] = prerenderResult.Html;
Run Code Online (Sandbox Code Playgroud)
另外,我看到了Angular Universal的这个谷歌教程,但他们使用的是NodeJS
服务器,而不是ASP.NET Core
.
我想使用服务器端预呈现.我通过这种方式添加元标记:
import { Meta } from '@angular/platform-browser';
constructor(
private metaService: Meta) {
}
let newText = "Foo data. This is test data!:)";
//metatags to publish this …
Run Code Online (Sandbox Code Playgroud) c# asp.net-core angular-universal asp.net-core-webapi angular
如果我把connect
从doStuff
,我得到的消息"套接字连接",但callback
不叫.我在这里错过了什么?
$scope.connect = function() {
var defer = $q.defer();
ws = new WebSocket("ws://server.com:port");
ws.onopen = function(){
console.log("Socket connected");
defer.resolve("socket connected");
};
return defer.promise;
}
$scope.doStuff = function() {
$scope.connect().then(function(data) {
console.log("And we're off!", data);
});
}
Run Code Online (Sandbox Code Playgroud) 因此,我想对我的数据进行常规分类。我有这段代码从数据库中获取数据,该数据库将仅提取包含的数据value
。
using System.Linq.Dynamic;
public static IQueryable<object> SortList(string searchString, Type modelType,
IQueryable<object> model)
{
....
string toStringPredicate = type == typeof(string) ? propertyName +
".Contains(@0)" : propertyName + ".ToString().Contains(@0)";
model = model.Where(propertyName + " != NULL AND " + toStringPredicate, value);
}
Run Code Online (Sandbox Code Playgroud)
该模型是这样的:
public class ManageSubscriberItems
{
public int? UserId { get; set; }
public string Email { get; set; }
public Guid SubscriberId { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
当我打电话时:
models = (IQueryable<ManageSubscriberItems>)EcommerceCMS.Helpers.FilterHelper
.SortList(searchString, typeof(ManageSubscriberItems), models);
if(models.Any())
Run Code Online (Sandbox Code Playgroud)
它引发此错误:
“ …
c# ×6
arrays ×2
asp.net-core ×2
linq ×2
angular ×1
angularjs ×1
asp.net ×1
dynamic ×1
dynamic-linq ×1
excel ×1
javascript ×1
oracle ×1
php ×1
phpexcel ×1
resources ×1
sql ×1
sql-server ×1
websocket ×1
wpf ×1