程序设计

专业和发烧友程序员的问答

12
使用WPF / MVVM Light Toolkit处理窗口关闭事件
我想处理Closing我窗口的事件(当用户单击右上角的“ X”按钮时),以便最终显示确认消息或/和取消关闭。 我知道如何在后面的代码中执行此操作:订阅Closing窗口的事件,然后使用CancelEventArgs.Cancel属性。 但是我使用的是MVVM,所以我不确定这是个好方法。 我认为好的方法是将Closing事件绑定到Command我的ViewModel中。 我尝试过: <i:Interaction.Triggers> <i:EventTrigger EventName="Closing"> <cmd:EventToCommand Command="{Binding CloseCommand}" /> </i:EventTrigger> </i:Interaction.Triggers> RelayCommand在我的ViewModel中带有一个关联,但是它不起作用(命令的代码未执行)。
145 c#  wpf  xaml  mvvm  mvvm-light 

8
正确实现IDisposable
在我的课程中,我实现IDisposable的方式如下: public class User : IDisposable { public int id { get; protected set; } public string name { get; protected set; } public string pass { get; protected set; } public User(int UserID) { id = UserID; } public User(string Username, string Password) { name = Username; pass = …

10
CSS background-image-正确的用法是什么?
CSS background-image属性的正确用法是什么?我想了解的关键是 是否需要用引号引起来,即: background-image: url('images/slides/background.jpg'); 可以是相对路径(如上所述)还是必须是完整URL? 我应该注意的其他事项,以确保它在符合标准的浏览器中正常运行。
145 css 

3
跨域表单过帐
我已经看过有关该主题的文章和帖子(包括SO),并且普遍的评论是,同源策略阻止跨域的POST形式。我见过有人建议将同源政策不适用于表单帖子的唯一位置是此处。 我想从一个更“官方”或正式的来源获得答案。例如,是否有人知道解决同源性如何影响表单POST的RFC? 澄清:我不是在问是否可以构造GET或POST并将其发送到任何域。我在问: 如果Chrome,IE或Firefox允许域“ Y”中的内容将POST发送到域“ X” 如果接收POST的服务器实际上将看到所有表单值。我之所以这样说,是因为大多数在线讨论记录的测试人员都说服务器收到了该帖子,但是表单值全部为空/已剥离。 哪个正式文档(即RFC)说明了预期的行为(无论浏览器当前已实现了什么)。 顺便说一句,如果同源源不影响表单POST,那么这使得为什么需要使用防伪令牌更加明显。我之所以说“有点”,是因为很难相信攻击者可以简单地发出HTTP GET来检索包含反伪造令牌的表单,然后进行包含相同令牌的非法POST。注释?

16
响应式图像图
我有一个响应式html布局中的现有图像映射。图像根据浏览器大小缩放,但是图像坐标显然是固定的像素大小。我必须选择哪些选项来调整图像地图坐标的大小?
145 html  css  imagemap 

8
您如何将图像上传到要点?
您如何将图像上传到要点? 看看这个:https : //gist.github.com/mbostock/5503544#file-thumbnail-png 我尝试过的是在要点的编辑模式下拖放图像文件。在Crhome和FireFox下,这似乎不起作用。 更新:在通过GitHub来回发送电子邮件之后,不支持此功能(拖放二进制文件,图像)。
145 github  gist 



4
Android:如何以编程方式设置布局的大小
作为Android应用程序的一部分,我正在构建按钮集。这些按钮是一组LinearLayouts的一部分。使用权重,我可以根据包含父级LinearLayout的大小自动调整其大小。这个想法是基于屏幕的像素数和密度,将包含布局的大小设置为多个像素。并根据更改更改按钮的大小。 然后的问题是:如何调整布局的大小。 我已经尝试了几种建议的技术,但没有一种接近工作。这是构建按钮集的XML的子集: <LinearLayout android:layout_height="104pt" android:id="@+id/numberPadLayout" android:orientation="horizontal" android:layout_width="104pt" android:background="#a0a0a0" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" > <LinearLayout android:layout_weight="2" android:layout_height="fill_parent" android:id="@+id/linearLayout1" android:orientation="vertical" android:layout_width="wrap_content"> <Button android:text="1" android:id="@+id/button1" android:layout_weight="2" android:layout_width="fill_parent" android:layout_height="wrap_content"></Button> <Button android:text="4" android:id="@+id/button4" android:layout_weight="2" android:layout_width="fill_parent" android:layout_height="wrap_content"></Button> <Button android:text="7" android:id="@+id/button7" android:layout_weight="2" android:layout_width="fill_parent" android:layout_height="wrap_content"></Button> <Button android:text="-" android:id="@+id/buttonDash" android:layout_weight="2" android:layout_width="fill_parent" android:layout_height="wrap_content"></Button> </LinearLayout> <LinearLayout android:layout_weight="2" android:layout_height="fill_parent" android:id="@+id/linearLayout2" android:orientation="vertical" android:layout_width="wrap_content"> <Button …

14
我可以使用HTML5在<a>内嵌套<button>元素吗?
我正在执行以下操作: &lt;a href="www.stackoverflow.com"&gt; &lt;button disabled="disabled" &gt;ABC&lt;/button&gt; &lt;/a&gt; 效果很好,但出现HTML5验证错误,提示“元素'button'不能嵌套在元素'a button'内”。 谁能给我建议我该怎么做?
145 html 

11
等待未来的清单
我有一种返回List期货的方法 List&lt;Future&lt;O&gt;&gt; futures = getFutures(); 现在,我要等到所有期货都成功完成处理,或者期货输出返回的任何任务都抛出异常。即使一项任务引发异常,也没有必要等待其他期货。 简单的方法是 wait() { For(Future f : futures) { try { f.get(); } catch(Exception e) { //TODO catch specific exception // this future threw exception , means somone could not do its task return; } } } 但是这里的问题是,例如,如果第4个期货抛出异常,那么我将不必要地等待前3个期货可用。 如何解决呢?会以任何方式倒计时闩锁帮助吗?我无法使用Future,isDone因为Java文档说 boolean isDone() Returns true if this …

13
Python,Unicode和Windows控制台
Наэтотвопросестьответына 堆栈溢出нарусском:Какиз的PythonвывестинаWindows的консольстрокувЮникоде? 当我尝试在Windows控制台中打印Unicode字符串时,出现UnicodeEncodeError: 'charmap' codec can't encode character ....错误。我认为这是因为Windows控制台不接受仅Unicode字符。最好的办法是什么?有什么方法可以使Python自动打印?而不是在这种情况下失败? 编辑: 我正在使用Python 2.5。 注意:带有对勾标记的@ LasseV.Karlsen答案有点过时(自2008年起)。请谨慎使用以下解决方案/答案/建议! 截至今天(2016年1月6日),@ JFSebastian的答案更有意义。
145 python  unicode 

12
使用GitHub Client for Windows在PATH中安装Git
在PATHWindows上使用GitHub客户端时,如何在自己的系统中安装Git ? 我遇到了错误,因为显然Git未安装在PATH中。例如,使用Atom尝试安装Linter插件会出现以下错误: npm ERR! not found: git npm ERR! npm ERR! Failed using git. npm ERR! This is most likely not a problem with npm itself. npm ERR! Please check if you have git installed and in your PATH. Windows版GitHub在安装时是否会安装Git?(它必须,否则它将如何使用Git?)我不想对其进行双重安装...那么,如何将已经存在的Git添加到PATH?



By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.