对于WPFcolorAnimation边框画笔颜色抛出“System.Windows.Markup.XamlParseException”感兴趣的读者,本文将会是一篇不错的选择,我们将详细介绍wpft
对于WPF colorAnimation 边框画笔颜色抛出“System.Windows.Markup.XamlParseException”感兴趣的读者,本文将会是一篇不错的选择,我们将详细介绍wpf textbox 边框颜色,并为您提供关于.net – System.Drawing(GDI)vs System.Windows.Media(WPF)vs Direct2D DirectWrite WIC、ASP.NET Core 3.1:System.InvalidCastException:无法将“System.Int32”类型的对象转换为“System.Int64”类型、Automapper 错误:System.InvalidOperationException:'缺少从 System.String 到 System.Char 的映射、C# WPF 中的错误:“System.Windows.Style”不是属性“System.Windows.Controls.Control.Template” MainViewResource.xaml主窗口.xaml的有用信息。
本文目录一览:- WPF colorAnimation 边框画笔颜色抛出“System.Windows.Markup.XamlParseException”(wpf textbox 边框颜色)
- .net – System.Drawing(GDI)vs System.Windows.Media(WPF)vs Direct2D DirectWrite WIC
- ASP.NET Core 3.1:System.InvalidCastException:无法将“System.Int32”类型的对象转换为“System.Int64”类型
- Automapper 错误:System.InvalidOperationException:'缺少从 System.String 到 System.Char 的映射
- C# WPF 中的错误:“System.Windows.Style”不是属性“System.Windows.Controls.Control.Template” MainViewResource.xaml主窗口.xaml
WPF colorAnimation 边框画笔颜色抛出“System.Windows.Markup.XamlParseException”(wpf textbox 边框颜色)
如何解决WPF colorAnimation 边框画笔颜色抛出“System.Windows.Markup.XamlParseException”
我正在尝试使用 Style.Triggers
在边框画笔上实现彩色动画。
viewmodel 改变了每个 Border 颜色有界的集合。
我猜 UI 元素没有初始化但是条件满足然后抛出异常:
“附加信息:无法解析属性路径 ''BorderBrush.Color'' 中的所有属性引用。请验证适用的对象是否支持这些属性。”
这里是 View.cs.xaml
代码:
<HierarchicalDataTemplate DataType="{x:Type model:SchemaNode}"
ItemsSource="{Binding Children}">
<Border CornerRadius="40">
<Border.Style>
<Style targettype="Border">
<Setter Property="Background" Value="{DynamicResource MaterialDesignPaper}"/>
<Style.Triggers>
<DataTrigger Binding="{Binding Closed}" Value="True">
<Setter Property="Background" Value="{Binding Outline}" />
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
<Border.InputBindings>
<MouseBinding MouseAction="LeftDoubleClick"
Command="{Binding ondoubleclick}" CommandParameter="{Binding GlobalId}"/>
</Border.InputBindings>
<Border.ContextMenu>
<ContextMenu ItemsSource="{Binding ContextActions}" Width="150" Placement="Mouse">
<ContextMenu.ItemTemplate>
<DataTemplate DataType="{x:Type helper:ContextAction}">
<MenuItem Header="{Binding Header}" Command="{Binding Command}"/>
</DataTemplate>
</ContextMenu.ItemTemplate>
</ContextMenu>
</Border.ContextMenu>
<Border BorderThickness="3" CornerRadius="360"
BorderBrush="{Binding Outline}" Width="{Binding Width}" Height="{Binding Height}">
<Border.Style>
<Style targettype="Border">
<Style.Triggers>
<DataTrigger Binding="{Binding Located}" Value="True">
<DataTrigger.Enteractions>
<BeginStoryboard x:Name="LocatedBeginStoryBoard">
<Storyboard Duration="0:0:0.5" RepeatBehavior="Forever" AutoReverse="True">
<ThicknessAnimation Storyboard.TargetProperty="BorderThickness" Duration="0:0:0.4"
FillBehavior="HoldEnd"
To="5"/>
<ThicknessAnimation Storyboard.TargetProperty="BorderThickness"
FillBehavior="HoldEnd"
BeginTime="0:0:0.4"
To="5"/>
<ColorAnimation Storyboard.TargetProperty="BorderBrush.Color"
To="White"/>
</Storyboard>
</BeginStoryboard>
</DataTrigger.Enteractions>
<DataTrigger.Exitactions>
<RemoveStoryboard BeginStoryboardName="LocatedBeginStoryBoard"/>
</DataTrigger.Exitactions>
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
<Image Height="50"
Width="50" Source="{Binding ImageSource,Converter={StaticResource imagePathToImageConverter}}"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Image.InputBindings>
<MouseBinding MouseAction="LeftDoubleClick" Command="{Binding ondoubleclick}" CommandParameter="{Binding GlobalId}"/>
</Image.InputBindings>
</Image>
</Border>
</Border>
</HierarchicalDataTemplate>
希望我提供了足够的代码来解决这个问题。
解决方法
您通过 BorderBursh
绑定的 Outline
很可能不是 SolidColorBrush
而是 GradientBrush
或只是未分配,因此没有 Color
属性.
您可以通过分配 SolidColorBrush
(directyl 或 via 样式)来测试这一点。
<Style TargetType="Border">
<Style.Setters>
<Setter Property="BorderBrush" Value="Blue"/>
</Style.Setters>
<!-- etc -->
.net – System.Drawing(GDI)vs System.Windows.Media(WPF)vs Direct2D DirectWrite WIC
此外,如果有人知道一个好的和详细的比较图表,列出了并排的不同功能和等价物,以及不支持的,这将是伟大的!例如,WPF和Direct2D中是否存在ColorMatrix等价物?例如,在研究了SharpDX对Direct2D的实现后,我留下的印象是即使微软将其定位为GDI的完全替代品,我也无法在Direct2D中找到所有GDI的功能.
另外,考虑到它是2014年,你会说至少对于图像处理(如果不是UI的一部分,WPF似乎是更好的选择),GDI在接下来的5年左右会好吗?或者我应该真的考虑使用所有3种技术,哪种方法效果最好?
谢谢.
解决方法
根据您的预期用途,我将使用以下方法:
>尽可能使用WPF名称空间,即System.Windows.Media.据我所知,System.Drawing和GDI通常使用非托管资源,这可能会产生不希望的,可避免的问题;
>尽可能严格地使用MVVM架构.也就是说,您有一个仅用于显示信息的View层,以及包含业务逻辑的Model和viewmodel层.虽然有些人可能会说视觉内容不属于viewmodel层,但如果你的应用程序处理图像操作,那么你的业务逻辑就像定义一样与View相关(我花了很长时间才弄明白这一点).
>如有疑问,请使用多维数组(在Model / viewmodel中)执行图像处理,并将这些数组绑定到View(使用ValueConverter通过DataBinding).
这样,例如,您可以使用ImageLayerviewmodel类来表示Layer,其中Data属性(或Value或PixelArray或Raster,无论如何)是double [height,width,depth].
我可以详细说明一下,但我不确定是否正确回答你的问题,所以如果你愿意,可以写任何评论.
ASP.NET Core 3.1:System.InvalidCastException:无法将“System.Int32”类型的对象转换为“System.Int64”类型
如何解决ASP.NET Core 3.1:System.InvalidCastException:无法将“System.Int32”类型的对象转换为“System.Int64”类型
Picture Error
我的控制器:
[HttpDelete("{roomId}")]
public async Task<IActionResult> Delete(string roomId)
{
var affectedResult = await _manageRoomService.Delete(roomId);
if (affectedResult == 0)
return BadRequest();
return Ok();
}
我的服务:我尝试调试,但它在代码块 foreach (var image in images)
中停止。
public async Task<int> Delete(string roomId)
{
var room = await _context.Rooms.FindAsync(roomId);
if (room == null)
throw new EWebHotelException($"Cannot find a room: {roomId}");
var images = _context.RoomImages.Where(i => i.RoomId == roomId);
foreach (var image in images)
{
await _storageService.DeleteFileAsync(image.ImagePath);
}
_context.Rooms.Remove(room);
return await _context.SaveChangesAsync();
}
我在 FileStorageService.cs 中的方法:
public async Task DeleteFileAsync(string fileName)
{
var filePath = Path.Combine(_userContentFolder,fileName);
if (File.Exists(filePath))
{
await Task.Run(() => File.Delete(filePath));
}
}
在 RoomImages 表中,列 Id
的类型为 int 32。
Automapper 错误:System.InvalidOperationException:'缺少从 System.String 到 System.Char 的映射
如何解决Automapper 错误:System.InvalidOperationException:''缺少从 System.String 到 System.Char 的映射
我需要使用 automapper 从 Company 模型中填充 CompanyVM 中的地址字段。一个公司可能有许多地址。最好我想要一个也是主要的活动地址。否则,我只想要一个活动地址。如果不行,给我一个地址。
这是公司模型:
public class Company
{
public int CompanyID { get; set; }
public string Name { get; set; }
public string Type { get; set; }
public string Industry { get; set; }
public string DBA { get; set; }
public string TaxID { get; set; }
public bool Active { get; set; } = true;
public virtual ICollection<Address> Addresses { get; set; } = new List<Address>();
这是地址模型:
public class Address
{
public int AddressID { get; set; }
public string Type { get; set; }
public string Street1 { get; set; }
public string Street2 { get; set; }
public string City { get; set; }
public string State { get; set; }
public string ZipCode { get; set; }
public string County { get; set; }
public string Country { get; set; }
public bool Primary { get; set; } = false;
public bool Active { get; set; } = true;
public int? CompanyCompanyID { get; set; }
我需要绘制其中的许多地图,但现在只是想让它为 Street1 工作。
以下是我尝试使用的自动映射器语句:
public class CompanyProfile : Profile
{
public CompanyProfile()
{
CreateMap<Company,CompanyVM>()
.ForMember(vm => vm.Street,opt => opt.MapFrom(model =>
model.Addresses.Where(x => x.CompanyCompanyID != null && x.Active && x.Primary).Select(x => x.Street1) ??
model.Addresses.Where(x => x.CompanyCompanyID != null && x.Active).Select(x => x.Street1) ??
model.Addresses.Where(x => x.CompanyCompanyID != null).Select(x => x.Street1)))
.ReverseMap();
}
}
这是 CompanyVM:
[Grid2(nameof(CompanyID),FavoritesEnabled = true,RecentRecordAction = "Details",FetchDataOnLoad = true
)]
public class CompanyVM : GridRecordVM
{
public virtual int CompanyID { get; set; }
[GridColumn2(TemplateType = GridTemplateType.DefaultDetailLink,IncludeInGeneralSearch = true)]
public virtual string Name { get; set; }
[GridColumn2]
public virtual string Type { get; set; }
[LockedFilter(FilterOperator.IsEqualTo,true)]
public virtual bool Active { get; set; }
[display(Name = "Industry")]
[MaxLength(20,ErrorMessage = "Industry cannot be longer that 20 characters.")]
public string Industry { get; set; }
[display(Name = "DBA")]
[MaxLength(50,ErrorMessage = "DBA name cannot be longer that 50 characters.")]
public string DBA { get; set; }
[display(Name = "Tax Id")]
[MaxLength(50,ErrorMessage = "TaxID name cannot be longer that 50 characters.")]
public string TaxID { get; set; }
[display(Name = "Street",Description = "Street")]
public string Street { get; set; }
//these items set to ignoremap until mapping sorted out
[display(Name = "City",Description = "City")]
[IgnoreMap]
public string City { get; set; }
[display(Name = "State",Description = "State")]
[IgnoreMap]
public string State { get; set; }
[display(Name = "ZipCode",Description = "ZipCode")]
[IgnoreMap]
public string ZipCode { get; set; }
[Phone]
[display(Name = "Phone Number",Description = "Phone Number")]
[IgnoreMap]
public string PhoneNumber { get; set; }
[EmailAddress]
[display(Name = "Email Address",Description = "Email Address")]
[IgnoreMap]
public string EmailAddress { get; set; }
}
抛出运行时错误:system.invalidOperationException: ''Missing map from System.String to System.Char。使用 CreateMap
解决方法
解决方案是将 CreateMap .ForMember 语句格式化如下:
CreateMap<Company,CompanyVM>()
.ForMember(x => x.Street,opt => opt.MapFrom(src =>
src.Addresses.Where(x => x.Active && x.Primary).FirstOrDefault() != null
? src.Addresses.Where(x => x.Active && x.Primary).FirstOrDefault().Street1
: src.Addresses.Where(x => x.Active).FirstOrDefault() != null
? src.Addresses.Where(x => x.Active).FirstOrDefault().Street1
: src.Addresses.FirstOrDefault() != null
? src.Addresses.FirstOrDefault().Street1
: string.Empty))
C# WPF 中的错误:“System.Windows.Style”不是属性“System.Windows.Controls.Control.Template” MainViewResource.xaml主窗口.xaml
如何解决C# WPF 中的错误:“System.Windows.Style”不是属性“System.Windows.Controls.Control.Template” MainViewResource.xaml主窗口.xaml?
我正在使用 WPF MVVM 模式,并在 MainViewResource.xaml
中制作了控件的样式。
通常没有问题,但是当Slider
中包含Control
时,会出现以下错误。
''System.Windows.Style'' 不是属性 ''System.Windows.Controls.Control.Template'' 的有效值。
运行该应用程序没有问题,但 xaml 屏幕上不显示 Control
。
MainViewResource.xaml
<Style targettype="{x:Type Slider}" x:Key="SLD.INPUT">
...
<Setter Property="Template">
<Setter.Value>
<ControlTemplate targettype="{x:Type Slider}">
<ControlTemplate.Resources>
...
</ControlTemplate.Resources>
<Border x:Name="border">
<Grid>
<DockPanel>
<Border x:Name="PART_SelectionRange">
<Rectangle x:Name="sliderBar"/>
</Border>
<Border>
<Rectangle x:Name="PART_NegativeSelection"/>
</Border>
</DockPanel>
<Track x:Name="PART_Track">
<Track.Thumb>
<Thumb x:Name="thumb"/>
</Track.Thumb>
</Track>
</Grid>
</Border>
<ControlTemplate.Triggers>
<DataTrigger Binding="{Binding ElementName=thumb,Path=IsMouSEOver}" Value="true">
<Setter TargetName="sliderBar" Property="Fill" Value="{StaticResource LGB.SLD.FG.OVER}"/>
</DataTrigger>
<DataTrigger Binding="{Binding ElementName=thumb,Path=IsDragging}" Value="true">
<Setter TargetName="sliderBar" Property="Fill" Value="{StaticResource LGB.SLD.FG.DRAG}"/>
</DataTrigger>
<Trigger Property="IsEnabled" Value="false">
<Setter TargetName="PART_SelectionRange" Property="Visibility" Value="Collapsed"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style targettype="{x:Type Control}" x:Key="CTL.INPUT">
<Setter Property="Grid.Row" Value="1"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate targettype="{x:Type Control}">
<ControlTemplate.Resources>
<Style targettype="{x:Type TextBlock}" x:Key="IN.CONTENT">
...
<Setter Property="Text" Value="{Binding ElementName=slider2,Path=Value,Converter={StaticResource StringFormatConverter}}"/>
</Style>
</ControlTemplate.Resources>
<Grid>
<Grid.ColumnDeFinitions>
<ColumnDeFinition Width="Auto"/>
<ColumnDeFinition Width="*"/>
</Grid.ColumnDeFinitions>
<Slider x:Name="slider2"/> // I guess here is the problem.
<TextBlock/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
主窗口.xaml
<Control/>
xaml 屏幕没有显示如下内容...
但是,当执行时,控件显示正确。
MainViewResource.xaml
正确注册到App.xaml
,其他控件的样式没问题。仅当使用 Slider 的自定义样式作为 StaticResource
时才会出现问题。有谁知道我错过了什么?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
关于WPF colorAnimation 边框画笔颜色抛出“System.Windows.Markup.XamlParseException”和wpf textbox 边框颜色的问题我们已经讲解完毕,感谢您的阅读,如果还想了解更多关于.net – System.Drawing(GDI)vs System.Windows.Media(WPF)vs Direct2D DirectWrite WIC、ASP.NET Core 3.1:System.InvalidCastException:无法将“System.Int32”类型的对象转换为“System.Int64”类型、Automapper 错误:System.InvalidOperationException:'缺少从 System.String 到 System.Char 的映射、C# WPF 中的错误:“System.Windows.Style”不是属性“System.Windows.Controls.Control.Template” MainViewResource.xaml主窗口.xaml等相关内容,可以在本站寻找。
本文标签: