<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:CustomCalc">
<Style TargetType="{x:Type local:CustomControl1}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:CustomControl1}">
<TextBlock Text="welcome" Height="50" Width="150" MouseDown=""/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
Run Code Online (Sandbox Code Playgroud)
在上面的程序中,(在自定义控件库中的程序i锻炼中)我试图更改控件textblock =>按钮.(文本块充当按钮功能)所以我尝试向文本块添加事件它给出了一条错误消息"确保事件失败",并且此文件名为"Generic.xaml",因此我添加了一个类"Generic.xaml.cs",但显示了相同的错误.请提前解释,请解释为什么会发生以及如何解决.
List<double> Values = new List<double>();
foreach (var item in Level.Items)
{
Values.Add(item.Keys);
}
Run Code Online (Sandbox Code Playgroud)
我是LINQ-Queries的新手,所以任何人都可以帮助如何在LINQ-Queries中编写上述代码.
double indexValues = 0;
var filterValues = Values as List<double> ?? Values as List<string>;
return (from val in filterValues select indexValues++).ToList();
Run Code Online (Sandbox Code Playgroud)
它说,
Operator '??' cannot be applied to operands of type 'List<double>' and 'List<string>'
Run Code Online (Sandbox Code Playgroud)
这Values是IEnumerable,有人可以帮我解决这个错误吗?