我在代码中有一个事件处理程序,当我期望它只被调用一次时,我看到它被多次调用.
在过去,这是因为我已经将委托定义在错误的位置(所以更多的是将一个委托添加到事件处理列表中),但是在这种情况下,这只会被设置一次(在类构造函数中).
而不是继续手动搜索我的代码寻找错误,我可以采取(简单)实用的方法来确定事件处理程序的分配位置?
几个月来,我在SL 3应用程序中成功使用了David Justices Default Button示例.此方法基于附加属性.
升级到SL4后,该方法不再有效,我得到一个XAML异常:
未知的解析器错误:扫描程序2148474880
有人在SL4中成功使用过这个(或任何其他)默认按钮附加行为吗?
有没有其他方法可以在SL4中使用可用的新类实现默认按钮行为?
谢谢,马克
我有这个用Zebra打印机打印的代码(RW 420具体)
StringBuilder sb = new StringBuilder();
sb.AppendLine("N");
sb.AppendLine("q609");
sb.AppendLine("Q203,26");
//set printer character set to win-1250
sb.AppendLine("I8,B,001");
sb.AppendLine("A50,50,0,2,1,1,N,\"za?ó?? g??l? ja??\"");
sb.AppendLine("P1");
printDialog1.PrinterSettings = new System.Drawing.Printing.PrinterSettings();
if (printDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
byte[] bytes = Encoding.Unicode.GetBytes(sw.ToString());
bytes = Encoding.Convert(Encoding.Unicode, Encoding.GetEncoding(1250), bytes);
int bCount = bytes.Length;
IntPtr ptr = System.Runtime.InteropServices.Marshal.AllocCoTaskMem(bCount);
System.Runtime.InteropServices.Marshal.Copy(bytes, 0, ptr, bytes.Length);
Common.RawPrinterHelper.SendBytesToPrinter(printDialog1.PrinterSettings.PrinterName, ptr, bCount);
}
Run Code Online (Sandbox Code Playgroud)
RawPrinterHelper是我从这里得到的微软课程.
我的问题是只打印ASCII字符,如下所示:
za g l ja
Run Code Online (Sandbox Code Playgroud)
缺少非ASCII字符.
有趣的是,当我打开记事本并将相同的文本放在那里并在Zebra打印机上打印时,所有字符都可以.
我通过MSTSC从我的笔记本电脑访问我的桌面.在RDC会话中,我选择了允许访问打印机和剪贴板的本地资源的选项.
我可以从我的本地笔记本电脑复制并粘贴到我的remore桌面,但无法从我的遥控器复制并粘贴到我的本地.这上周工作,但现在已经停止.
什么设置可能已更改?
谢谢,马克
我的 APIEndToEndTests位于两个不同的容器中,当我构建 docker-compose.yml 时,出现连接被拒绝异常。
失败的
PagingSystem.MessageQueue.EndToEndTests.Test.ValueControllerTest.Get_AllValues_ReturnsTrue
| Error Message:
| System.Net.Http.HttpRequestException : Connection refused
| ---- System.Net.Sockets.SocketException : Connection refused
| Stack Trace:
| at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
| at System.Threading.Tasks.ValueTask1.get_Result()
| at System.Net.Http.HttpConnectionPool.CreateConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
| at System.Threading.Tasks.ValueTask1.get_Result()
Run Code Online (Sandbox Code Playgroud)
下面是我的 docker(API 和 End2End)、docker-compose.yml 和 appsetting.json 文件:
API 码头工人
FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM microsoft/dotnet:2.1-sdk AS build
WORKDIR /src
COPY Source/PagingSystem.MessageQueue/PagingSystem.MessageQueue.csproj Source/PagingSystem.MessageQueue/
RUN dotnet restore Source/PagingSystem.MessageQueue/PagingSystem.MessageQueue.csproj
COPY . . …Run Code Online (Sandbox Code Playgroud) 我的一个开发应用程序今天开始显示美国格式的短日期,而我期待的是英国格式。
日期正在使用date.ToShortDateString()
我已经检查了我的区域设置、键盘设置、浏览器设置和 web.config。这些都设置为英语(英国)或未更改。我也重启过很多次了。
从同一开发服务器运行的同一应用程序的移动版本和同一网站(不同的 Web 应用程序)运行正常。
环境:
还有哪些地方可以更改区域设置,从而可能影响日期的显示?
我们正在尝试从 DateTime 变量中删除时间:
DECLARE @Date DateTime
SET @Date = '01Jan2013 23:59:59.998'
PRINT DATEADD(dd, 0, DATEDIFF(dd, 0, @Date ))
SET @Date = '01Jan2013 23:59:59.999'
PRINT DATEADD(dd, 0, DATEDIFF(dd, 0, @Date ))
Run Code Online (Sandbox Code Playgroud)
结果:
2013年1月1日 12:00
2013年1月2日 12:00
为什么01Jan2013 23:59:59.999回来是1 月 2 日而不是 1 月 1 日?
我可以在Silverlight中使用generic.xaml来设置应用程序中所有TextBlock的样式吗?
<ResourceDictionary xmlns="http://schemas.microsoft.com/client/2007"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="TextBlock">
<Setter Property="Foreground"
Value="White" />
<Setter Property="FontSize"
Value="24" />
</Style>
</ResourceDictionary>
Run Code Online (Sandbox Code Playgroud)
我期待这个工作,但它没有:-(
什么是在整个应用程序中应用样式的最简单方法?
谢谢,马克
编辑
感谢您的答复.我没有收到错误,样式没有被应用.我在互联网上找到的所有例子(包括你列出的例子)都是为自定义控件设计的.我可以这样做,但我想设置默认控件的样式:
<TextBlock Text="Style me!!" Grid.Row="2" />
Run Code Online (Sandbox Code Playgroud)
我是否需要添加来自page.xaml的generic.xaml的引用?我是否需要将generic.xaml样式命名并引用为资源?
再次感谢,马克
如何使用knockout绑定创建以下日历网格?:

将有7列.(每天一个).表格的第一行(标题)将包含日期和日期.第二行将包含相应日期的值.下一行将是另一个标题,后面再跟着值.重复直到月末.
我将所有数据都放在一个可观察的集合对象中:
function CalendarDate(id, date, volume) {
var self = this;
self.id = ko.observable(id);
self.date = ko.observable(date);
self.volume = ko.observable(volume);
};
function ForecastViewModel() {
var self = this;
self.dates = ko.observableArray([]);
}
Run Code Online (Sandbox Code Playgroud)
我觉得我应该使用foreach绑定,但无法弄清楚如何在第7列之后包装网格.
有任何想法吗?
UserManager.GetUserAsync(authState.User)UserManager除非已经被调用,否则会抛出异常。
例如;
这引发NullReferenceException了await UserManager.GetUserAsync(authState.User);
@ page "/"
@inject UserManager<ApplicationUser> UserManager
<AuthorizeView>
...
</AuthorizeView>
@code{
[CascadingParameter]
private Task<AuthenticationState> authenticationStateTask { get; set; }
protected async override Task OnInitializedAsync()
{
var authState = await authenticationStateTask;
var currentUser = await UserManager.GetUserAsync(authState.User); // exception here
}
}
Run Code Online (Sandbox Code Playgroud)
但这工作正常;
@ page "/"
@inject UserManager<ApplicationUser> UserManager
<AuthorizeView>
...
</AuthorizeView>
@code{
[CascadingParameter]
private Task<AuthenticationState> authenticationStateTask { get; set; }
protected async override Task OnInitializedAsync()
{
var allUsers = UserManager.Users.ToList(); // hack …Run Code Online (Sandbox Code Playgroud) c# ×2
asp.net ×1
asp.net-core ×1
blazor ×1
clipboard ×1
coding-style ×1
datetime ×1
docker ×1
epl ×1
iis ×1
knockout.js ×1
silverlight ×1
sql-server ×1
t-sql ×1
utf-8 ×1
windows-7 ×1
zpl ×1