突然间,我在检查我的本地主分支时开始收到以下错误.问题文件以及错误本身似乎是随机的(有时结帐工作完全正常).
"c:\ Program Files(x86)\ Git\bin\git.exe"checkout --merge"master"D abc123.cs错误:无法创建文件abc123.cs(权限被拒绝)切换到分支'master'完成
从代码隐藏中很容易做到这一点:
var button = new Button();
var margin = button.Margin;
margin.Right = 10;
button.Margin = margin;
Run Code Online (Sandbox Code Playgroud)
但是,在XAML中,我仅限于以下内容:
<Button Margin="0,0,10,0" />
Run Code Online (Sandbox Code Playgroud)
这个问题是,现在我可能通过将其设置为零来覆盖其他边距值(即左边,上边,下边).
有没有办法让XAML像下面那样?
<Button MarginRight="10" />
Run Code Online (Sandbox Code Playgroud) 在从F#库项目中定位.NET Core时,我在某些NuGet包(例如Newtonsoft.Json和Microsoft.EntityFrameworkCore.SqlServer)中打开命名空间时遇到了一些麻烦.
以下是导致我的问题的步骤:
从https://www.microsoft.com/net/core#windows安装"Visual Studio 2015 Update 3"和".NET Core 1.0.1 - VS 2015 Tooling Preview 2"
创建了一个包含以下内容的空解决方案:
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Run Code Online (Sandbox Code Playgroud)在解决方案目录中创建一个空项目目录
在空项目目录中,运行命令:
dotnet new -t lib --lang f#
Run Code Online (Sandbox Code Playgroud)
它创建了一个Library.fs文件:
namespace Library
module Say =
let hello name =
printfn "Hello %s" name
Run Code Online (Sandbox Code Playgroud)
和project.json文件:
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"compilerName": "fsc",
"compile": { …Run Code Online (Sandbox Code Playgroud)考虑来自我的 UserControl 的以下 XAML:
<TextBlock Text="HelloWorld" Loaded="TextBlock_OnLoaded" />
Run Code Online (Sandbox Code Playgroud)
以及相关的事件处理程序:
private void TextBlock_OnLoaded(object sender, RoutedEventArgs e)
{
var xaml = XamlWriter.Save(sender);
Console.WriteLine(xaml);
}
Run Code Online (Sandbox Code Playgroud)
加载 TextBlock 后,以下输出将写入控制台:
<TextBlock Text="HelloWorld" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" />
Run Code Online (Sandbox Code Playgroud)
现在考虑这个替代 XAML:
<ListBox ItemsSource="{Binding SomeCollection}">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="HelloWorld" Loaded="TextBlock_OnLoaded" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Run Code Online (Sandbox Code Playgroud)
现在,当加载 TextBlock 时,以下输出将写入控制台:
<TextBlock xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" />
<TextBlock xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" />
<TextBlock xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" />
......
Run Code Online (Sandbox Code Playgroud)
请注意 TextProperty 不再被序列化。
如果在调用 XamlWriter.Save() 之前添加了以下 TextProperty 分配:
private void TextBlock_OnLoaded(object sender, RoutedEventArgs e)
{
var textBlock = sender as TextBlock;
if (textBlock != …Run Code Online (Sandbox Code Playgroud) 考虑以下程序:
using System;
using System.Threading.Tasks;
public class Program
{
public static void Main()
{
var stringTask = Task.FromResult("sample");
stringTask.TeeAsync(st => Task.CompletedTask).Wait();
}
}
public static class FunctionalExtensions
{
public static async Task<T> TeeAsync<T>(this T source, Func<T, Task> asyncAction)
{
await Task.Delay(0); // todo: do something with source
return source;
}
public static async Task<T> TeeAsync<T>(this Task<T> asyncSource, Func<T, Task> asyncAction)
{
var source = await asyncSource;
await Task.Delay(0); // todo: do something with source
return source;
}
}
Run Code Online (Sandbox Code Playgroud)
第9行上的编译器错误因为而TeeAsync …
c# ×2
wpf ×2
xaml ×2
.net ×1
.net-core ×1
f# ×1
generics ×1
git ×1
mvvm ×1
mvvm-light ×1
nuget ×1
wpf-controls ×1
xamlwriter ×1