小编luc*_*mon的帖子

强制 WPF DataGrid 添加特定新项目的最佳方法是什么?

DataGrid在 WPF 应用程序中有ItemsSource一个我编写的自定义集合。该集合强制其所有项目满足某个要求(即它们必须介于某个最小值和最大值之间)。

集合的类签名是:

   public class CheckedObservableCollection<T> : IList<T>, ICollection<T>, IList, ICollection,
                                            INotifyCollectionChanged
                                             where T : IComparable<T>, IEditableObject, ICloneable, INotifyPropertyChanged
Run Code Online (Sandbox Code Playgroud)

我希望能够使用这样的DataGrid功能,即在DataGrid结果的最后一行提交编辑,将新项目添加到ItemsSource.

Unfortunately the DataGrid simply adds a new item created using the default constructor. So, when adding a new item, DataGrid indirectly (through its ItemCollection which is a sealed class) declares:

ItemsSource.Add(new T())
Run Code Online (Sandbox Code Playgroud)

where T is the type of elements in the CheckedObservableCollection. I would like for the grid to …

wpf datagrid datacontract itemssource type-constraints

3
推荐指数
1
解决办法
1538
查看次数

了解subview.center = view.center的工作原理以及getter和setter执行不同操作的原因

我看到很多代码解释了如何在视图中居中子视图.代码示例通常如下所示:

SubView.center = view.center;
Run Code Online (Sandbox Code Playgroud)

有人可以向我解释这是如何工作的吗?我只是不明白.

view.center给出了视图的中心点.例如,宽度为100,高度为100,它将返回(50,50).我知道了.

设置subview.center对我来说很奇怪. subview.center将返回子视图的中心点.不知何故,将其设置为(50,50)会将子视图定位在其父级中,坐标为50/50.但是如果子视图本身宽度为50且高度为50,则访问此属性将返回let(),然后返回(25,25).

我的意思是什么?这里的概念对我来说很奇怪,因为setter和getter正在做不同的功能.

如果有人可以解释这个,请做.或者,如果我离开基地,我也想知道.我是iOS开发的新手.

如果我是正确的,这确实是它的工作方式,你不会认为这是一种反模式.当然,在.NET中,这样的东西就是反模式.也许不适合Obj-C?

objective-c xamarin.ios ios

3
推荐指数
1
解决办法
3364
查看次数

如何在android中制作文本动画?

在我的 android 应用程序中,我试图显示每 100 毫秒更改一次的“正在加载...”文本。每 100 毫秒后,它会增加一个点。所以首先它会像“加载”。又过了 100 毫秒,它将是 "Loading.." 当它是 "Loading..." 时,这个过程将终止并再次从第一个单词开始。它将持续到 3500 毫秒。它会很像进度条。

我希望我能够解释这个问题。

如何解决这个问题?请帮忙。

android

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

暂停和恢复翻译动画

我正在使用翻译动画来移动ImageView.我正在使用此代码:

TranslateAnimation set1 = new TranslateAnimation(-4, 10, -110, 0);
        set1.setDuration(3000);
        TranslateAnimation set2 = new TranslateAnimation(10, -3, 0, 115);
        set2.setDuration(3000);
        set2.setStartOffset(2200);
        TranslateAnimation set3 = new TranslateAnimation(-3, -20, 0, -100);
        set3.setDuration(3000);
        set3.setStartOffset(4500);
        TranslateAnimation set4 = new TranslateAnimation(0, 13, 0, -120);
        set4.setDuration(3000);
        set4.setStartOffset(6500);

        animSet.addAnimation(set1);
        animSet.addAnimation(set2);
        animSet.addAnimation(set3);
        animSet.addAnimation(set4);

        animSet.setFillAfter(true);
Run Code Online (Sandbox Code Playgroud)

创建一组动画后,我将它们应用于ImageView以下内容:

image = (ImageView)findViewById(R.id.img);
        image.startAnimation(animSet);
Run Code Online (Sandbox Code Playgroud)

一切都运行正常,但我不能暂停动画并继续点击按钮.

我怎样才能做到这一点?

我尝试了一切,但没有成功.知道怎么做吗?

请帮忙!

java android android-animation

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

未调用RequireJS错误回调(errback)

我正在使用RequireJS编写模块化的Web应用程序,用于模块加载和依赖项注入。

从我的bootstrap.js文件I负荷Application.js和初始化它,传递要被“加载”的模块阵列(1)通过Application。初始化完成后,Application会调用函数来告知已完成加载。

我正在使用异步加载模块(相对于彼此)require(["module"], callback(module), callback(error))

我遇到的问题是,当模块加载失败时(至少在服务器以404状态代码响应时,至少在Chrome上),未调用错误回调(errback)。

我可以在Google Chrome开发者工具控制台中看到该错误,但未调用errback:

GET http://192.168.1.111:8812/scripts/modules/InexistentModule/manifest.js 404 (Not Found) 
Uncaught Error: Load timeout for modules: modules/InexistentModule/manifest 
Run Code Online (Sandbox Code Playgroud)

有没有人遇到过与RequireJS错误有关的此问题?如果是这样,怎么办?

(1)实际上,我只是加载模块清单,而不是整个模块,以便我可以为它们显示图标并使用Backbone.SubRoute注册其路由。

我正在使用的库(都没有缩小):

  • 需求JS 1.0.8
  • 下划线1.6.0
  • jQuery 1.11.0
  • 骨干1.1.2
  • 骨干子路由0.4.1

在上面的库中,目前我仅直接使用RequireJS和Underscore。

当将成功/失败回调传递给Require时,我使用了Underscore进行curry,以便i从我的循环中传递index参数。对于成功的回调,它的运行效果非常好,我认为这不会影响到errback(我已经使用Arity 1的简单函数进行了测试,而不是返回的部分函数,_.partial并且在404的情况下仍未调用该函数错误)。

我将在此处发布我的bootstrap.jsApplication.js文件,因为它们可能会提供更多信息。

谢谢!

bootstrap.js

require.config({
    catchError: true,
    enforceDefine: true,
    baseUrl: "./scripts",
    paths: {
        "jquery": "lib/jquery",
        "underscore": "lib/underscore",
        "backbone": "lib/backbone",
        "backbone.subroute": "lib/backbone.subroute"
    },
    shim: {
        "underscore": { …
Run Code Online (Sandbox Code Playgroud)

javascript error-handling requirejs

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

c ++简单程序错误

untitled1.cpp使用以下脚本创建了一个名为dev-cpp 的文件:

#include <iostream.h>
using namespace std;
int main(){
    cout << "C++";
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

但编译器显示如下错误:

1 F:\ Dev-Cpp\include\c ++\3.4.2\backward\iostream.h:31,
来自F:\ Dev-Cpp\Untitled1.cpp in include/c ++/3.4.2/backward/iostream中包含的文件.h:31,来自F:\ Dev-Cpp\Untitled1.cpp 32:2 F:\ Dev-Cpp\include\c ++\3.4.2\backward\backward_warning.h #warning此文件至​​少包含一个已弃用或过时的文件头.请考虑使用C++标准第17.4.1.2节中的32个标头之一.示例包括将标头替换为C++包含的标头,或者代替不推荐使用的标头.要禁用此警告,请使用-Wno-deprecated.

我有什么错误?我如何解决它?

c++ iostream include deprecated

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

php中的字符串比较

我试图比较HTML中的密码表单中的两个字符串.

它们存储在变量中$_POST.我打印出来看起来一样,但下面的代码永远不会评估为真,只有假.为什么会这样?

//Verify the passwords match
if( ($passwd != $pass_confirm) && ($new_email != $email_confirm) ){
    echo "Email and/or password do not match";
    return FALSE;
}
Run Code Online (Sandbox Code Playgroud)

我感谢任何帮助.

html php string

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

在格鲁里亚日历的Java中的错误

我想89天内陆续新增到CurrentDate通过GregorianCalendar其返回31/04/2015.以下是代码段.

Calendar now = Calendar.getInstance(); 
String dt="31012013";  
now.set(Integer.parseInt(dt.substring(4)),Integer.parseInt(dt.substring(2,4)),Integer.parseInt(dt.substring(0,2))); 
now.add(Calendar.DATE, 89); 
String matdate=Integer.toString(now.get(Calendar.DATE))+ "/"+ (now.get(Calendar.MONTH) ) +"/" + now.get(Calendar.YEAR); 
Run Code Online (Sandbox Code Playgroud)

执行此代码后,matdate值将于31/04/2013发布

java

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

如何在android应用程序中实现cookie

我想在Android中创建一个登录应用程序.

项目的要求是使用cookie存储用户名和密码两天.

可以使用cookies吗?如果是,那怎么样?你能给我代码吗?

注意:我无法使用Web视图.

cookies android

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