我有一个自定义标记扩展“ThemeExtension”,用于从我的 DefaultTheme.xaml ResourceDictionary 提供“SolidColorBrush”。
调用示例:BorderBrush="{extensions:Theme Key= FooKeyValue}"
它在运行时运行没有任何问题,但有时它在设计时开始崩溃,我无法再开发。设计师崩溃了。重建、清理解决方案、操作系统重新启动不再有帮助。如果我更改 XAML 代码内部的某些值,它正好适用于 1 个绘图!然后它又崩溃了!
bei System.Windows.Setter.Seal()
bei System.Windows.SetterBaseCollection.Seal()
bei System.Windows.Style.Seal()
bei System.Windows.StyleHelper.UpdateStyleCache(FrameworkElement fe, FrameworkContentElement fce, Style oldStyle, Style newStyle, Style& styleCache)
bei System.Windows.FrameworkElement.OnStyleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
bei System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
bei System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
bei System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
bei System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
bei System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp, Boolean preserveCurrentValue)
bei System.Windows.FrameworkElement.UpdateStyleProperty()
bei System.Windows.FrameworkElement.OnInitialized(EventArgs e)
bei System.Windows.Controls.Primitives.Selector.OnInitialized(EventArgs e)
bei System.Windows.FrameworkElement.TryFireInitialized()
bei …Run Code Online (Sandbox Code Playgroud) 我想alarms在我的服务器应用程序上注册。为了防止传递 10+ 个参数,我alarm在客户端序列化我的并将其传递List<JSONString>给我的服务器。反序列化它,注册它并给出注册的alarm.
现在我的问题是,我不知道如何传递这些参数:
类型为 \"[String]!\" 的变量 \"$params\" 用于期望类型 \"[DictionaryType]!\" 的位置。"
“无法将值转换为 AST:System.Collections.Generic.Dictionary`2[System.String,System.Object]”,**
public class Mutation : ObjectGraphType
{
public Mutation()
{
Name = "Mutation";
FieldAsync<HtStaticAlarmBaseType>(
"registerStaticAlarms",
"Register a list with static alarms.",
arguments: new QueryArguments(
new QueryArgument<NonNullGraphType<ListGraphType<DictionaryType>>> {Name = "params"}
),
resolve: async context =>
{
List<object> parameterString = context.GetArgument<List<object>>("params");
//TODO
return null;
}
);
}
}
Run Code Online (Sandbox Code Playgroud)
我有一个带有NUnit测试项目的解决方案(Foo.Test)。
+-- src
| +-- Foo.Gui
| +-- Foo.Test
Run Code Online (Sandbox Code Playgroud)
+-- src
| +-- Foo.Gui
| +-- Foo.Test
Run Code Online (Sandbox Code Playgroud)
以下调用用于测试:
dotnet test --no-build -c Release -v n src\%TESTPROJECT%\%TESTPROJECT%.csproj --logger "trx;LogFileName=testreport.trx"
如果我在本地运行它,一切都会按预期工作:
对构建服务器的相同调用没有找到任何测试:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<Compile Remove="TestResults\**" />
<EmbeddedResource Remove="TestResults\**" />
<None Remove="TestResults\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="GitVersionTask" Version="5.1.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="nunit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Foo.Gui\Foo.Gui.csproj" …Run Code Online (Sandbox Code Playgroud) 我的项目文件夹中有两个项目:
HtSuite.UWP | LibraryHtSuite.UWP.Leitstand | Applicaton在Libraryis an 中UserControl NamePasswordControl,我可以在XAML | Designer.
当我将NamePasswordControl放在我的LoginView.xaml(也在Library)上时,出现以下错误:
由于缺少程序集,无法显示元素“passwordView”。构建应用程序后,您可能能够查看此控件
当我运行时Application,一切都按预期工作。
到目前为止我尝试了以下步骤(没有成功):
dotnet cleandotnet restorev16.6.0) 并尝试了v16.7.0 预览版 1有人知道如何修复预览吗?
https://files.dominic-jonas.de/stackoverflow/ClassLibrary2.zip
一个类库,其中有一个 UserControl 和一个应在其上显示的页面。但是,错误也显示在那里,无法预览
我有一个Grid动态的大小.在里面我想画一个对角线TextBlock.我已经有一个对角线Path,您可以设置LineGeometry动态调整.但我找不到吊坠TextBlock.我错过了什么吗?
<Grid>
<TextBlock Text="Draft" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="180" FontWeight="Bold" Foreground="#FFA43A3A" RenderTransformOrigin="0.5,0.5"/>
<Path Grid.Row="2" Grid.Column="0" Stroke="Red" StrokeThickness="2" Stretch="Fill">
<Path.Data>
<LineGeometry StartPoint="1,0" EndPoint="0,1" />
</Path.Data>
</Path>
</Grid>
Run Code Online (Sandbox Code Playgroud)
这是我希望没有设置绝对值RotateTransform.
该red前景FrankM的解决方案,green一个是从亨利克·汉森
我有以下问题。我有一个带有 DataGridTemplateColumn 的 DataGrid,我想用弹出窗口显示单元格的文本(因为它可以被修剪)。
这是我的 xaml 代码:
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock
Text="{Binding Description}"
TextTrimming="CharacterEllipsis">
<TextBlock.ToolTip>
<ToolTip Style="{StaticResource ToolTipBrowserDescription}" ToolTip="test"/>
</TextBlock.ToolTip>
</TextBlock>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
Run Code Online (Sandbox Code Playgroud)
风格:
<Style TargetType="{x:Type ToolTip}" x:Key="ToolTipBrowserDescription">
<Setter Property="DataContext" Value="{Binding RelativeSource={x:Static RelativeSource.Self}}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToolTip}">
<Border BorderBrush="{StaticResource HT_Background_DarkGrey}" Background="{StaticResource HT_Background_LightGrey3}" BorderThickness="1">
<TextBlock Text="{Binding ToolTip}" FontWeight="Bold" TextWrapping="Wrap" Margin="5" MinWidth="50" MaxWidth="{TemplateBinding MaxWidth}"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Run Code Online (Sandbox Code Playgroud)

但是,当我将工具提示属性从“test”设置为“{Binding Description}”时,工具提示(如图所示)为空。
有没有人给我解决方案。我被困了大约2小时..
我已将我的全部包裹SQL Connections在一个using声明中。
using (DbConnection dbConnection = GetConnection())\n{\n using (DbCommand dbCommand = dbConnection.CreateCommand(cmdInsert))\n {\n //some work\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n\n因为UnitTests我应该使用 a :memory: database,但是database关闭连接后会自动删除。
https://www.sqlite.org/inmemorydb.html
\n\n\n\n\n当与数据库的最后一个连接关闭时,数据库将被自动删除并回收内存。
\n
有没有解决方案如何使用 a:memory: database和 use using?我不想在没有..的情况下编写完全相同的代码两次using。
public abstract class SqliteBase\n{\n public string ConnectionString;\n\n protected SqliteBase()\n { \n SQLiteConnectionStringBuilder builder = new SQLiteConnectionStringBuilder\n {\n DataSource = ":memory:",\n ForeignKeys = true,\n DefaultTimeout = 3,\n DateTimeKind …Run Code Online (Sandbox Code Playgroud) 我有一个文件夹,Resources想要获取所有paths.
如果我将它们设置为 an embedded resource,我可以通过
var resources = Assembly.GetExecutingAssembly().GetManifestResourceNames();
Run Code Online (Sandbox Code Playgroud)
当遵循这个答案/sf/answers/135452481/ 时,我不应该再使用embedded resource了,或者我做错了什么?
我在我的DataContext内部使用DesignTime WPF Styles获得全面IntelliSense支持.
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:alarm="clr-namespace:Foo.Alarm;assembly=HtCore"
mc:Ignorable="d">
<Style TargetType="TreeViewItem" d:DataContext="{d:DesignInstance alarm:HtAlarmBase}">
</Style>
</ResourceDictionary>
Run Code Online (Sandbox Code Playgroud)
但Designer highlights它并说:
" http://schemas.microsoft.com/expression/blend/2008 "命名空间中不存在"DataContext"属性
是否有隐藏此"错误消息"的解决方案?
在ViewModel是一个
public List<string> OperationModes { get; } = Enum.GetNames(typeof(EOperationMode)).ToList();
Run Code Online (Sandbox Code Playgroud)
我想绑定到ComboBox.
this.OneWayBind(ViewModel, model => model.OperationModes, window => window.ComboBoxOperationMode.ItemsSource).DisposeWith(r);
Run Code Online (Sandbox Code Playgroud)
如果使用reactiveUI将 绑定list到ComboBox,我会在console output.
控制台输出
DefaultViewLocator: Failed to resolve view for view model type 'System.Object'.
DefaultViewLocator: Failed to resolve view for view model type 'System.Object'.
ViewModelViewHost: The ViewModelViewHost could not find a valid view for the view model of type System.String and value Passthrough.
Run Code Online (Sandbox Code Playgroud)
<ComboBox
x:Name="ComboBoxOperationMode" …Run Code Online (Sandbox Code Playgroud) 通常我会检查我是否可以访问ObservableCollection,如果没有,我会调用一个Dispatcher. 这里(上Stackoverflow)还有其他一些解决方案,但我不知道什么是最好和最干净的方法。我认为我的解决方案已经过时,不应再使用。
在我的例子中是ItemsCollection绑定到UI. 该_UpdateTheCollectionFromAnotherThread()会被调用(从另一个thread或将开启另一个thread)并保存数据暂时到items。之后,我会检查访问权限并dispatcher在需要时调用 a 。
这是我必须走的路还是有一些更好更清洁的解决方案?
public class FooClass
{
// ##############################################################################################################################
// Properties
// ##############################################################################################################################
/// <summary>
/// This Items are bound to my UI.
/// </summary>
public ObservableCollection<string> ItemsCollection { get; } = new ObservableCollection<string>();
// ##############################################################################################################################
// Singleton pattern
// ##############################################################################################################################
/// <summary>
/// The instance of <see cref="FooClass"/>.
/// </summary>
internal static FooClass Instance …Run Code Online (Sandbox Code Playgroud) 我有一个Task FooTask应该在后台调用的。中的一个新功能C# 7.0是discard函数。正如已经问过的(C# 7.0 独立丢弃混淆),可以通过Task两种方式调用。但是,我还没有能够确切地找出这两个调用有何不同以及它们是否有任何区别。
_ = Task.Run(FooTask);
Run Code Online (Sandbox Code Playgroud)
_ = FooTask();
Run Code Online (Sandbox Code Playgroud) c# ×10
wpf ×6
xaml ×4
.net ×2
asynchronous ×1
blend ×1
c#-7.0 ×1
data-binding ×1
dispatcher ×1
dotnet-test ×1
graphql ×1
nunit ×1
reactiveui ×1
resharper ×1
sqlite ×1
unit-testing ×1
uwp ×1
uwp-xaml ×1