我有一个已排序的列表框,需要显示每个项目的行号.在这个演示中,我有一个带有Name字符串属性的Person类.列表框显示按名称排序的人员列表.如何添加到列表框的datatemplate行号?
XAML:
<Window x:Class="NumberedListBox.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="300" Width="300">
<ListBox
ItemsSource="{Binding Path=PersonsListCollectionView}"
HorizontalContentAlignment="Stretch">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=Name}" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Window>
Run Code Online (Sandbox Code Playgroud)
代码背后:
using System;
using System.Collections.ObjectModel;
using System.Windows.Data;
using System.Windows;
using System.ComponentModel;
namespace NumberedListBox
{
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
Persons = new ObservableCollection<Person>();
Persons.Add(new Person() { Name = "Sally"});
Persons.Add(new Person() { Name = "Bob" });
Persons.Add(new Person() { Name = "Joe" });
Persons.Add(new Person() { Name = "Mary" });
PersonsListCollectionView = …Run Code Online (Sandbox Code Playgroud) Jasmine的初学者,与Jasmine Spies的第一次尝试.我以为我在模仿这里显示的格式(搜索:"andReturn"),但我收到一个错误,我无法解决:
TypeError: Object function () {
callTracker.track({
object: this,
args: Array.prototype.slice.apply(arguments)
});
return spyStrategy.exec.apply(this, arguments);
} has no method 'andReturn'
Run Code Online (Sandbox Code Playgroud)
不知道我做错了什么.这是我的规格:
describe('Die', function() {
it('returns a value when you roll it', function() {
var die = Object.create(Die);
spyOn(Math, 'random').andReturn(1);
expect(die.roll()).toEqual(6);
});
});
Run Code Online (Sandbox Code Playgroud)
和相应的JS:
var Die =
{
roll: function() {
return Math.floor(Math.random() * 5 + 1);
}
}
Run Code Online (Sandbox Code Playgroud)
谢谢您的帮助!!!
我不是在谈论代码编辑器.我已经导入了我的Visual Studio设置来更改项目文件的颜色标记我现在想要使用Visual Studio库中的Theme插件将Visual Studio的主题更改为更暗的主题.是否有任何地方可以获得预制的黑暗主题,因为它附带的默认主题非常差?
我正在尝试做一些我认为很容易做的事情,即通过匹配正则表达式将字符串限制为某些字符.
var value = 'FailureStr1ng';
var type = 'ALPHA';
var regex = null;
switch(type) {
case 'ALPHA':
regex = '^[a-zA-Z]+$';
break;
case 'NUMERIC':
regex = '^[0-9]+$';
break;
case 'ALPHANUMERIC':
regex = '^[a-zA-Z0-9]+$';
break;
}
return value.match(regex);
Run Code Online (Sandbox Code Playgroud)
出于某种原因,当使用匹配时,它总是返回null.有没有办法解决这个问题,或者更好的方法来解决这个问题?
注意:这里的代码是一个包含更大代码的代码段,而值和类型变量通常由另一个方法定义.
Microsoft.NET框架提供了IDisposable需要实现void Dispose()方法的接口.其目的是IDisposable实现可能已分配实施的昂贵资源的手动或基于范围的发布.示例包括数据库集合,流和句柄.
我的问题是,如果该Dispose()方法的实现是幂等的 - 当在同一个实例上多次调用时,该实例仅被"处置"一次,并且后续调用不会抛出异常.在Java中,大多数具有相似行为的对象(作为示例再次出现流和数据库连接)对于它们的close()操作是幂等的,这恰好是该Dispose()方法的模拟.
但是,我个人使用.NET(特别是Windows Forms)的经验表明,并非所有实现(它们都是.NET框架本身的一部分)都是幂等的,因此后续调用这些实现会引发争议ObjectDisposedException.这真的让我对如何处理一次性对象的实现感到困惑.该场景是否有共同的答案,还是取决于对象的具体上下文及其用法?
我是.NET的新手.我有兴趣使用Dapper micro-ORM从ASP .NET应用程序访问MySQL后端.
可以这样做吗?开始时我需要知道什么?
说我有一个字符串s = 'BINGO'; 我想迭代字符串来生成'B I N G O'.
这就是我做的:
result = ''
for ch in s:
result = result + ch + ' '
print(result[:-1]) # to rid of space after O
Run Code Online (Sandbox Code Playgroud)
有没有更有效的方法来解决这个问题?
我在其中使用带有ProgressDialog的AsyncTask.这会自动导致背景暗淡约40%.我想把这个昏暗的(0%暗淡),但我尝试过,但没有用:
myLoadingDialog = new ProgressDialog(MainActivity.this.getApplicationContext());
myLoadingDialog.setMessage("Loading...");
myLoadingDialog.setIndeterminate(true);
myLoadingDialog.setCancelable(false);
WindowManager.LayoutParams lp = myLoadingDialog.getWindow().getAttributes();
lp.dimAmount = 0.0f;
myLoadingDialog.show();
Run Code Online (Sandbox Code Playgroud)
这个昏暗的问题是,我必须终止我的Tablet的SystemUI-Process以实现Kiosk模式(没有System-Bar),并且ProgressDialog使除了System-Bar所在的区域之外的所有内容都变暗,所以我有一个明亮的边框在屏幕的底部.
如果有办法获得完整的全屏模式,我也会很开心.
谢谢你的帮助
我已经在FF和Safari(包括iDevices)中测试了我的视频并且播放正常,但它无法在Chrome浏览器中播放.正如您在下面的代码中看到的,我创建了mp4,m4v,webM和ogv文件,并且我已经在我的计算机上测试了所有这些文件以解决任何播放问题.
在Chrome中,视频似乎已加载,并且控制台日志中没有错误.按下播放按钮时,它会加载文件的一部分,但之后不会播放.然而,有趣的是,如果我在时间栏中随意点击一下,说到中途,即使有字幕,也会播放大约5秒的视频,但没有音频.
我已经阅读了可能导致此问题的任何问题,但我没有找到任何有用的想法.要注意,我在.htaccess文件中写了以下内容:
# ----------------------------------------------------------------------
# Proper MIME type for all files
# ----------------------------------------------------------------------
# Audio
AddType audio/ogg oga ogg
AddType audio/mp4 m4a
AddType audio/webm webm
# Video
AddType video/ogg ogv
AddType video/mp4 mp4 m4v
AddType video/webm webm
# Assorted types
AddType image/x-icon ico
AddType image/webp webp
AddType text/cache-manifest appcache manifest
AddType text/x-component htc
AddType application/x-chrome-extension crx
AddType application/x-opera-extension oex
AddType application/x-xpinstall xpi
AddType application/octet-stream safariextz
AddType application/x-web-app-manifest+json webapp
AddType text/x-vcard …Run Code Online (Sandbox Code Playgroud) c# ×3
.net ×2
javascript ×2
android ×1
asp.net ×1
css ×1
dapper ×1
html ×1
html5 ×1
html5-video ×1
idempotent ×1
jasmine ×1
listbox ×1
mysql ×1
python ×1
regex ×1
string ×1
tdd ×1
unit-testing ×1
vssettings ×1
wpf ×1