我有一个简单的窗口,其中嵌入了一个简单的复合控件.
(主窗口)
<Window x:Class="TabOrder.Window1"
xmlns:local="clr-namespace:TabOrder"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Grid>
<Label HorizontalAlignment="Left" VerticalAlignment="Top">First</Label>
<TextBox TabIndex="0" HorizontalAlignment="Stretch" VerticalAlignment="Top" Margin="80,0,0,0"/>
<Label HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,30,0,0">Second</Label>
<TextBox TabIndex="1" HorizontalAlignment="Stretch" VerticalAlignment="Top" Margin="80,30,0,0"/>
<local:MyControl Margin="0,60,0,0" VerticalAlignment="Top" HorizontalAlignment="Stretch" TabIndex="2"/>
</Grid>
Run Code Online (Sandbox Code Playgroud)
(复合控制)
<UserControl x:Class="TabOrder.MyControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
<Label HorizontalAlignment="Left" VerticalAlignment="Top">Third</Label>
<TextBox HorizontalAlignment="Stretch" VerticalAlignment="Top" Margin="80,0,0,0"/>
<Label HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,30,0,0">Fourth</Label>
<TextBox HorizontalAlignment="Stretch" VerticalAlignment="Top" Margin="80,30,0,0"/>
</Grid>
Run Code Online (Sandbox Code Playgroud)
正如我预期的那样,我得到了4个文本框......
但是当"第一"有焦点而我点击标签时,焦点会切换到"第三".WPF似乎将选项卡列表视为单个平面列表,而不是作为一个树,其中MyControl是TabIndex 3,文本框"Third"是其中的第一个选项卡式控件.
这是WPF中的错误还是有其他方法可以做到这一点?复合控件在许多窗口中使用,甚至可以在单个窗口上使用多次.
我在脚本中使用EventSystem.current.IsPointerOverGameObject,Unity返回True,即使我发誓指针下面没有UI/EventSystem对象.
如何查找有关EventSystem正在检测的对象的信息?
我正在尝试向Angular的FormGroup类添加一个额外的方法,该类将从服务器设置组的状态+设置错误状态.
我form-helper.ts在Angular4应用程序的文件中有以下代码.
import { FormGroup } from '@angular/forms';
export interface FormGroup {
setValueAndErrors(state: any, memberErrors: any);
}
FormGroup.prototype.setValueAndErrors = (state: any, memberErrors: any) => {
this.setValue(state);
// do some stuff with the memberErrors parameter
}
Run Code Online (Sandbox Code Playgroud)
但是编译器会FormGroup.prototype.setValueAndErrors在行上抛出错误.
C中的错误:/dev/AppName/AppName-Client/src/app/shared/utils/form-helper.ts(3,21):类型'FormGroup'上不存在属性'setValueAndErrors'.
Program.MainBlazor WASM 应用程序中的方法具有string[] args参数。ASP.NET Core 主机站点是否可以将参数传递给这些?在构建应用程序之前,我需要能够从服务器读取值。
我尝试使用 FluentValidation 进行验证,object.GetType()而不是通过注入在编译时了解类型IValidator<T>,但我得到的是null值而不是有效的验证器。
组织+验证者
namespace ConsoleApp44
{
internal class Organisation
{
public string? Name { get; set; }
}
internal class OrganisationValidator: AbstractValidator<Organisation>
{
public OrganisationValidator()
{
RuleFor(x => x.Name).NotEmpty();
}
}
}
Run Code Online (Sandbox Code Playgroud)
使用它的控制台应用程序
var services = new ServiceCollection();
services.AddValidatorsFromAssemblyContaining<OrganisationValidator>();
services.Add(ServiceDescriptor.Scoped(typeof(IValidatorFactory), typeof(ServiceProviderValidatorFactory)));
var sp = services.BuildServiceProvider();
var org = new Organisation();
var validationFactory = sp.GetRequiredService<IValidatorFactory>(); // Not null
var validator = validationFactory.GetValidator(org.GetType()); // Null
validator = validationFactory.GetValidator<Organisation>(); // Null
validator = sp.GetRequiredService<IValidator<Organisation>>(); // Exception, …Run Code Online (Sandbox Code Playgroud) 当前表达式验证Web地址(HTTP),如何更改它以使空字符串也匹配?
(http|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?
Run Code Online (Sandbox Code Playgroud) var startPoint =
shaft.transform.position
+ shaft.transform.forward;
var ray = new Ray(
startPoint,
-shaft.transform.forward
);
RaycastHit rayCastHit;
Physics.Raycast(ray, out rayCastHit);
var textured2D = (Texture2D)discoBall.renderer.material.mainTexture;
Vector2 textureCoord = rayCastHit.textureCoord;
Debug.Log(string.Format(
"{0},{1} at distance {2}",
textureCoord.x * textured2D.width,
textureCoord.y * textured2D.height,
rayCastHit.distance
));
Run Code Online (Sandbox Code Playgroud)
我有一个球体,里面有一个物体"轴"物体.我计算出一个startPoint,它在轴指向的方向上离轴(离开球体).然后,我创建一条指向球体的光线,该光线具有相同的距离,以便它与我的球体外部相撞.
Debug.Log为textureCoord输出x,y = 0,0,为距离输出正确的值0.35.为什么textureCoord总是0,0当我确实在我的球体上有一个带有纹理的材质?

我有以下简单的扩展类
public static class ExpressionOrExtension
{
public static Expression<Func<T, bool>> Or<T>(this Expression<Func<T, bool>> source, Expression<Func<T, bool>> expression)
{
if (source == null)
return expression;
return Expression.Or(source, expression);
}
}
Run Code Online (Sandbox Code Playgroud)
但是 Expression.Or 返回 a BinaryExpression- 我怎样才能让它返回 anExpression<Func<T, bool>>呢?
这就是我尝试使用实体框架使用该方法的方式
public IQueryable<BookVerse> FindByVerseReferences(string bookCode, params VerseReference[] verseReferences)
{
Expression<Func<BookVerse, bool>> conditions = null;
foreach(VerseReference verseReference in verseReferences ?? new VerseReference[0])
{
conditions = conditions.Or<BookVerse>(x =>
x.BookCode == bookCode
&& x.Chapter == verseReference.Chapter
&& x.FirstVerse <= verseReference.LastVerse
&& x.LastVerse >= …Run Code Online (Sandbox Code Playgroud) 我将以下 HTML 添加到head我的 blogger.com 主题部分。
<link href='https://alexgorbatchev.com/pub/sh/current/styles/shCore.css' rel='stylesheet' type='text/css'>
<link href='https://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css' rel='stylesheet' type='text/css'>
<script src='https://alexgorbatchev.com/pub/sh/current/scripts/shCore.js' type='text/javascript'></script>
<script src='https://alexgorbatchev.com/pub/sh/current/scripts/shBrushCpp.js' type='text/javascript'></script>
<script src='https://alexgorbatchev.com/pub/sh/current/scripts/shBrushCSharp.js' type='text/javascript'></script>
<script src='https://alexgorbatchev.com/pub/sh/current/scripts/shBrushCss.js' type='text/javascript'></script>
<script src='https://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js' type='text/javascript'></script>
<script src='https://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js' type='text/javascript'></script>
<script src='https://alexgorbatchev.com/pub/sh/current/scripts/shBrushPhp.js' type='text/javascript'></script>
<script src='https://alexgorbatchev.com/pub/sh/current/scripts/shBrushPython.js' type='text/javascript'></script>
<script src='https://alexgorbatchev.com/pub/sh/current/scripts/shBrushRuby.js' type='text/javascript'></script>
<script src='https://alexgorbatchev.com/pub/sh/current/scripts/shBrushSql.js' type='text/javascript'></script>
<script src='https://alexgorbatchev.com/pub/sh/current/scripts/shBrushVb.js' type='text/javascript'></script>
<script src='https://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js' type='text/javascript'></script>
<script src='https://alexgorbatchev.com/pub/sh/current/scripts/shBrushPerl.js' type='text/javascript'></script>
<script language='javascript'>
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.config.clipboardSwf = 'https://alexgorbatchev.com/pub/sh/current/scripts/clipboard.swf';
SyntaxHighlighter.all();
</script>
Run Code Online (Sandbox Code Playgroud)
但是当我通过 HTTP 查看页面时,浏览器告诉我我正在HTTP从第二个HTTPS页面请求不安全的资源。
https://mrpmorris.blogspot.co.uk/2017/06/loading-assembly-from-specific-path.html
如果我右键单击 Chome 控制台中的 alexgorbatchev 链接并选择Open in new …
我有一个方法,它接收IEnumerable<Guid>我想要删除的对象的ID.一种建议的方法如下
foreach(Guid id in ids)
{
var tempInstance = new MyEntity { Id = id };
DataContext.Attach(tempInstance); // Exception here
DataContext.Remove(tempInstance);
}
Run Code Online (Sandbox Code Playgroud)
如果对象尚未加载到内存中,这可以正常工作.但我的问题是,当它们已经加载时,该Attach方法抛出一个InvalidOperationException - The instance of entity type 'MyEntity' cannot be tracked because another instance with the key value 'Id:...' is already being tracked.如果我DataContext.Remove不使用电话就会发生同样的事情Attach.
foreach(Guid id in ids)
{
var tempInstance = new MyEntity { Id = id };
DataContext.Remove(tempInstance); // Exception here
}
Run Code Online (Sandbox Code Playgroud)
我不想用来DataContext.Find抓取已经加载的对象的实例,因为如果它尚未加载,它会将对象加载到内存中.
我不能DataContext.ChangeTracker …
c# ×3
angular ×1
blazor ×1
blogs ×1
expression ×1
lambda ×1
linq ×1
regex ×1
tabindex ×1
typescript ×1
webassembly ×1
wpf ×1