好的,我有一个简单的IEnumerable<HtmlString> things,我想把它分成四个相等的组.
var quarter = things.Count() / 4;
Run Code Online (Sandbox Code Playgroud)
应该做的伎俩,但我得到这个funkiness:
'/'应用程序中的服务器错误.至少有一个对象必须实现IComparable.描述:执行当前Web请求期间发生未处理的异常.请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息.
异常详细信息:System.ArgumentException:至少有一个对象必须实现IComparable.
第36行:int quarter = things.Count()/ 4;
谁知道这里到底发生了什么?为什么我需要实现IComparable才能获得简单的计数?
这个问题看起来很奇怪但是从我的经验来看,我已经习惯了将键盘焦点设置为可聚焦元素,只需用鼠标点击即可; 然而,与用户控件的属性Focusable = true和IsTabStop = true出乎我,因为它通过标签获得键盘焦点,但保持无知鼠标点击.
我有一个RibbonComboBox用于设置字体大小.它有一个RibbonGallery列出各种字体大小,显示在适当的FontSize:
<r:RibbonComboBox DataContext="{x:Static vm:RibbonDataModel.FontSizeComboBoxData}"
SelectionBoxWidth="30">
<r:RibbonGallery MaxColumnCount="1"
Command="{Binding Command}"
CommandParameter="{Binding SelectedItem}">
<r:RibbonGallery.GalleryItemTemplate>
<DataTemplate>
<Grid>
<TextBlock Text="{Binding}"
FontSize="{Binding}" />
</Grid>
</DataTemplate>
</r:RibbonGallery.GalleryItemTemplate>
</r:RibbonGallery>
</r:RibbonComboBox>
Run Code Online (Sandbox Code Playgroud)
编辑这是我的ViewModel:
public static RibbonDataModel
{
public static GalleryData<object> FontSizeComboBoxData
{
get
{
lock (LockObject)
{
const string key = "Font Size";
if (!DataCollection.ContainsKey(key))
{
var value = new GalleryData<object>
{
Command = HtmlDocumentCommands.ChangeFontSize,
Label = "Change Font Size",
ToolTipDescription = "Set the font to a specific size.",
ToolTipTitle = "Change …Run Code Online (Sandbox Code Playgroud) wpf ribbon ribbon-control windows-ribbon-framework ribboncontrolslibrary
我正在尝试使用Html.DropDownListFor <> HtmlHelper并且在发布时遇到一些问题.HTML呈现正确但我在提交时从未获得"选定"值.
<%= Html.DropDownListFor( m => m.TimeZones,
Model.TimeZones,
new { @class = "SecureDropDown",
name = "SelectedTimeZone" } ) %>
Run Code Online (Sandbox Code Playgroud)
[Bind(Exclude = "TimeZones")]
public class SettingsViewModel : ProfileBaseModel
{
public IEnumerable TimeZones { get; set; }
public string TimeZone { get; set; }
public SettingsViewModel()
{
TimeZones = GetTimeZones();
TimeZone = string.Empty;
}
private static IEnumerable GetTimeZones()
{
var timeZones = TimeZoneInfo.GetSystemTimeZones().ToList();
return timeZones.Select(t => new SelectListItem
{
Text = t.DisplayName,
Value = t.Id
} );
}
}
Run Code Online (Sandbox Code Playgroud)
我尝试了一些不同的东西,我确信我做的事情很愚蠢......只是不确定它是什么:)
在v-data-table具有top狭槽,具有pagination支撑其结构相匹配,所述的footer槽。是否可以将top插槽分配给正在使用的相同(大概是一个v-pagination)控件footer?
我的目标是复制表格顶部的分页控件(位于页脚中)。
运行脚本时,我有一行代码来验证我们的应用程序是否存在“服务帐户”(也称为本地用户帐户):
$svcAccountName = "TheAccountName"
$svcAccount = Get-LocalUser -Name $svcAccountName
Run Code Online (Sandbox Code Playgroud)
服务器 (Windows Server 2008 R2) 对 cmdlet 犹豫不决Get-LocalUser,指出:
Get-LocalUser:术语“Get-LocalUser”未被识别为某个名称
cmdlet、函数、脚本文件或可操作程序。检查拼写
名称,或者如果包含路径,请验证路径是否正确,然后重试。
行:1 字符:1
+ 获取本地用户
+ ~~~~~~~~~~~~~
+ 类别信息:ObjectNotFound:(获取本地用户:字符串)[],CommandNotFoundException
+ FullQualifiedErrorId:CommandNotFoundException
所以我尝试导入该LocalAccounts模块:
Import-Module Microsoft.Powershell.LocalAccounts
Run Code Online (Sandbox Code Playgroud)
我得到了这个:
导入模块:未加载指定的模块“LocalAccounts”,因为没有
在任何模块目录中找到有效的模块文件。
行:1 字符:1
+ 导入模块
+ ~~~~~~~~~~~~~
+ 类别信息:资源不可用:(本地帐户:字符串)[导入模块],FileNotFoundException
+FullyQualifiedErrorId:Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
根据$PSVersionTable变量,服务器正在运行 PSVersion 4.0。
为什么模块没有LocalAccounts加载并且Get-LocalUser命令没有运行?我怎样才能解决这个问题?
Gu提供了一个示例,说明如何创建覆盖RegularExpressionAttribute的自定义验证程序.
这样做的好处是您不必创建自定义模型验证器,但我无法使其工作.
给出以下代码:
public class NameAttribute : RegularExpressionAttribute {
public NameAttribute()
: base(@"^[\w\s\-\']+$") {
}
}
Run Code Online (Sandbox Code Playgroud)
这有效:
[RegularExpression(@"^[\w\s\-\']+$")]
Run Code Online (Sandbox Code Playgroud)
但这不是:
[Name]
Run Code Online (Sandbox Code Playgroud)
我是否误解了Scott的一个方面的例子,或者是MVC不支持派生类型开箱即用的例子,所以实际上我必须创建一个相应的ModelValidator?
谁能看到我在这里做错了什么?该Assert.IsTrue(parses)总是失败.
[TestMethod]
public void Can_Parse_To_DateTime()
{
DateTime expected = new DateTime(2011, 10, 19, 16, 01, 59);
DateTime actual;
string value = "Wed Oct 19 16:01:59 PDT 2011";
string mask = "ddd MMM dd HH:mm:ss xxx YYYY";
bool parses = DateTime.TryParseExact(value, mask,
CultureInfo.InvariantCulture,
DateTimeStyles.None,
out actual);
Assert.IsTrue(parses);
Assert.AreEqual(expected, actual);
}
Run Code Online (Sandbox Code Playgroud)
我也这样尝试过,结果相同:
[TestMethod]
public void parsing()
{
DateTime expected = new DateTime(2011, 10, 19, 16, 01, 59);
DateTime actual;
string value = "Wed Oct 19 16:01:59 PDT 2011";
string mask …Run Code Online (Sandbox Code Playgroud) 当我开始调试我的第一个XamarinAndroid应用程序时,我设置了一些断点.无论我做什么,它仍然不会到达断点.这有什么问题?
我已经尝试了很多次,但它没有帮助.
我的文档中有以下XAML:
<Border HorizontalAlignment="Right" VerticalAlignment="Bottom"
Height="100" Width="100"
BorderBrush="Red" BorderThickness="2">
<Image x:Name="image"
Source="http://myinternalserver/mywebservice/getimage.aspx?id=1234&ContentType=Image" />
</Border>
Run Code Online (Sandbox Code Playgroud)
图像在Win10和Win8中显示得很好,但在Win7中,我得到的是一个透明背景的红色边框,里面没有图像.当我使用静态网址时,就像谷歌徽标一样,它会在所有版本中呈现.
任何人都知道如何在Windows 7中进行图像渲染?
asp.net-mvc ×3
c# ×3
wpf ×3
.net-4.0 ×1
android ×1
datetime ×1
debugging ×1
focus ×1
icomparable ×1
module ×1
powershell ×1
ribbon ×1
unit-testing ×1
v-data-table ×1
validation ×1
viewmodel ×1
vue.js ×1
vuejs2 ×1
vuetify.js ×1
windows-7 ×1
xamarin ×1
xaml ×1