小编Sha*_*aku的帖子

"此项目未引用程序集"WPF资源字典中的错误

创建一个名为的新WPF项目: xmlnsError

添加引用 PresentationFramework.Aero

将此添加ResourceDictionaryApp.xaml:

<ResourceDictionary Source="/PresentationFramework.Aero,Version=4.0.0.0,Culture=Neutral,PublicKeyToken=31bf3856ad364e35,processorArchitecture=MSIL;component/themes/Aero.NormalColor.xaml"/>
Run Code Online (Sandbox Code Playgroud)

这样做会显示警告

Assembly 'PresentationFramework.Aero,Version=4.0.0.0,Culture=Neutral,PublicKeyToken=31bf3856ad364e35,processorArchitecture=MSIL' is not referenced by this project
Run Code Online (Sandbox Code Playgroud)

我已经仔细检查以确保版本实际上4.0.0.0并且PublicKeyToken实际上是31bf3856ad364e35通过导航到C:\Windows\Microsoft.NET\assembly\GAC_MSIL\PresentationFramework.Aero以及在运行时通过查看来自的AssemblyInfo来检查GACAppDomain.CurrentDomain.GetAssemblies();

有没有办法解决这个警告?这是WPF Windows 8兼容性问题的后续问题

.net c# wpf xaml resourcedictionary

9
推荐指数
1
解决办法
2699
查看次数

为什么Xamarin ListView Cahcing策略显示"模糊参考"?

下面是"核心"项目中页面的屏幕截图.添加时CachingStrategy="RecycleElement",我收到了

"模糊参考"错误.

将鼠标悬停在它上面并没有提供有关如何修复它的任何其他信息,ReSharper也没有.

https://i.stack.imgur.com/KSEt5.png

xaml xamarin xamarin.forms

8
推荐指数
1
解决办法
1415
查看次数

参数中的Java"new"关键字

我最近一直在寻找很多OOP设计模式,我遇到了一些我以前从未见过的奇怪事情:

Button button =  new Button(shell, SWT.PUSH);
button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
    // Handle the selection event
    System.out.println("Called!");
    }
}); 
Run Code Online (Sandbox Code Playgroud)

具体来说,这是做什么的(例如,"new"关键字在这里做什么)?:

    button.addSelectionListener(new SelectionAdapter() {
Run Code Online (Sandbox Code Playgroud)

第二个问题:

private void notifyListeners(Object object, String property, String oldValue, String newValue) {
   for (PropertyChangeListener name : listener) {
      name.propertyChange(new PropertyChangeEvent(this, "firstName", oldValue, newValue));
   }
}
Run Code Online (Sandbox Code Playgroud)

这是观察者设计模式的片段.根据我的新理解,name.propertyChange(...)创建了一个PropertyChangeEvent对象,并通过Java的观察者模式实现,通过将这个新对象的信息发送给观察者(或者与此非常相似的东西)自动通知观察者.它是否正确?

java oop

7
推荐指数
1
解决办法
3189
查看次数

什么=>在Linq表达式中表示

*虽然这是一个重复的问题,但我之前从未在代码中看到过表达式"=>".如果我知道这是一个特别的lambda表达式,我会google'd并自己想出来.谢谢!

我是使用Linq的新手,所以当我在这段代码中遇到它时,使用"=>"确实让我很困惑:

using System;
using System.Linq;
using System.Collections.Generic;

public static class Extend
{
    public static double StandardDeviation(this IEnumerable<double> values)
    {
        double avg = values.Average();
        return Math.Sqrt(values.Average(v=>Math.Pow(v-avg,2)));
    }
}
Run Code Online (Sandbox Code Playgroud)

资料来源:通用清单的标准差?

几个问题:=>做什么?Intellisense告诉我'v'是一个int,但它从未声明过.这是如何运作的?

c# linq

5
推荐指数
2
解决办法
6131
查看次数

C# - 将对象转换为接口

假设我们有一个接口:

interface ICustomShape
{
}
Run Code Online (Sandbox Code Playgroud)

我们有一个继承自Shape类的类,并实现了接口:

public class CustomIsocelesTriangle : Shape, ICustomShape
{

}
Run Code Online (Sandbox Code Playgroud)

我如何将CustomIsocelesTriangle转换为ICustomShape对象,以便在"接口级别"上使用?

ICustomShape x = (ICustomShape)canvas.Children[0]; //Gives runtime error: Unable to cast object of type 'program_4.CustomIsocelesTriangle' to type 'program_4.ICustomShape'.
Run Code Online (Sandbox Code Playgroud)

.net c# casting interface class

5
推荐指数
1
解决办法
6320
查看次数

WPF Windows 8兼容性问题

给定一个按钮(或组合框,或任何控件):

<Button x:Name="button" Command="{Binding DoStuff}" Margin="10,0,5,5" Content="Do Stuff!" Style="{StaticResource buttonDefaults}"/>
Run Code Online (Sandbox Code Playgroud)

随风格:

<Style x:Key="buttonDefaults" TargetType="Button" BasedOn="{StaticResource {x:Type Button}}">
        <Style.Resources>
            <ResourceDictionary Source="/PresentationFramework.Aero;component/themes/Aero.NormalColor.xaml"/>
        </Style.Resources>
        <Setter Property="Background">
            <Setter.Value>
                <RadialGradientBrush>
                    <GradientStop Color="#F4083268" Offset="1"/>
                    <GradientStop Color="#FE5C9247"/>
                </RadialGradientBrush>
            </Setter.Value>
        </Setter>
        <Setter Property="BorderBrush" Value="Transparent"/>
        <Setter Property="Foreground" Value="White"/>
        <Setter Property="FontFamily" Value="Arial"/>
        <Setter Property="FontSize" Value="16"/>
        <Setter Property="Focusable" Value="False"/>
    </Style>
Run Code Online (Sandbox Code Playgroud)

它在Windows 8中看起来与在Windows 7中看起来非常不同.

现在,奇怪的是,在DESIGNER中,一切在Windows 8机器上看起来都很完美,就好像它是Windows 7 ......但在运行时,风格并没有"应用".

另一方面,它在设计器和运行时的Windows 7上看起来都很完美.有没有办法来解决这个问题?

额外细节:

随着风格的RD:

    <Style x:Key="buttonDefaults" TargetType="Button" BasedOn="{StaticResource {x:Type Button}}">
        <Style.Resources>
            <ResourceDictionary Source="/PresentationFramework.Aero,Version=4.0.0.0,Culture=Neutral,PublicKeyToken=31bf3856ad364e35,processorArchitecture=MSIL;component/themes/Aero.NormalColor.xaml"/>
        </Style.Resources>
        <Setter Property="Background">
            <Setter.Value>
                <RadialGradientBrush>
                    <GradientStop Color="#F4083268" Offset="1"/>
                    <GradientStop Color="#FE5C9247"/>
                </RadialGradientBrush> …
Run Code Online (Sandbox Code Playgroud)

c# wpf compatibility xaml resourcedictionary

5
推荐指数
1
解决办法
1476
查看次数

C#中的MergeSort实现

目前正在研究算法分析,而不是盲目地从我的教科书中运行伪代码,而是在C#中实现每个算法.这是伪代码:

MERGE-SORT(A,p,r)
1  if p < r
2     q = (p+r)/2
3     MERGE-SORT(A,p,q)
4     MERGE-SORT(A,q+1,r)
5     MERGE(A,p,q,r)

MERGE(A,p,q,r)
1  n1 = q - p + 1
2  n2 = r - q
3  let L[1..n1+1] and R[1..n2+1] be new arrays
4  for i = 1 to n1
5     L[i] = A[p+i-1]
6  for j = 1 to n2
7     R[j] = A[q+j]
8  L[n1+1] = INF
9  R[n1+1] = INF
10 i = 1
11 j = 1
12 for …
Run Code Online (Sandbox Code Playgroud)

c# sorting mergesort console-application

2
推荐指数
1
解决办法
6959
查看次数

奇怪的空对象引用错误

调用“sliderValue.Content = widthValue”(如下在滑块的 ValueChanged 事件处理程序中定义)时出现奇怪的空对象引用错误。

XAML:

<Window x:Class="StrangeError.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="166.066" Width="326.351">
<Grid>
    <Slider x:Name="widthSlider" HorizontalAlignment="Left" Margin="6,56,0,0" VerticalAlignment="Top" Width="257" TickFrequency="10" SmallChange="0.01" TickPlacement="BottomRight" IsSnapToTickEnabled="True" Ticks="1, 2, 3, 4, 5, 6, 7, 8, 9, 10" ValueChanged="widthSlider_ValueChanged" Minimum="1"/>

    <Label x:Name="sliderValue" Content="" HorizontalAlignment="Left" Margin="262,50,0,0" VerticalAlignment="Top"/>
</Grid>
Run Code Online (Sandbox Code Playgroud)

代码:

namespace StrangeError
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
    int widthValue;

    public MainWindow()
    {
        InitializeComponent();
        widthValue = 1;
        sliderValue.Content = 1;
    }

    private void widthSlider_ValueChanged(object sender, …
Run Code Online (Sandbox Code Playgroud)

c# wpf runtime-error event-handling nullreferenceexception

0
推荐指数
1
解决办法
1570
查看次数

如何使用Max扩展方法?

我真的很困惑如何使用扩展方法...我正在尝试使用来自http://msdn.microsoft.com/en-us/library/6sh2ey19.aspx的扩展max方法

我的(简化)代码:

namespace grades
{
    public class Grades
    {
        private List<int> grades;

        public int max()
        {
            return grades.Max(); // Not finding the extended Max function...
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我用错了吗?如果有人可以写出如何正确使用这些扩展方法的代码?

.net c# linq

-1
推荐指数
1
解决办法
604
查看次数