问题列表 - 第46786页

在WPF中,如何在设计视图中将样式应用于UserControl?

我通常在tab下的App.xml中定义样式和控件模板.因此,在设计UI时,我可以在带有.NET3.5的Visual Studio 2008中看到设计视图中应用了样式的UI.

但是,在另一种情况下,有时我只使用UserControl项目,在这种情况下,没有App.xml,因此UI在设计视图中显示为默认外观.在运行时很难知道实际的外观.

有没有办法将样式应用于UserControl?如果有一种方法可以在应用程序项目和UserControl项目之间共享相同的样式和模板,那将是完美的!

如果有解决方案,请告诉我.

c# wpf user-controls styles controltemplate

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

HTML解析器如何工作?

我已经看过幽默的线程并阅读警告,我知道你不用正则表达式解析HTML.别担心...... 我不打算尝试它.

但是......这让我想问:HTML解析器是如何编码的(包括编程语言的内置函数,如DOM解析器和PHP的strip_tags)?他们使用什么机制来解析(有时是格式错误的)标记?

我找到了一个用JavaScript编码,它实际上使用正则表达式来完成这项工作:

// Regular Expressions for parsing tags and attributes
var startTag = /^<(\w+)((?:\s+\w+(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)>/,
    endTag = /^<\/(\w+)[^>]*>/,
    attr = /(\w+)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|([^>\s]+)))?/g;  
Run Code Online (Sandbox Code Playgroud)

他们都这样做吗?是否有一种传统的标准方法来编写HTML解析器?

regex html-parsing

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

在Magento中添加Data.php Helper出错了

在自定义Magento系统配置中遵循Alan Storm教程,当我尝试添加时

帮助文件夹中的Data.php我仍然收到此错误:

致命错误:在第520行的E:\ xampp\htdocs\magento\app\Mage.php中找不到"Mage_Helloworld_Helper_Data"类

**Alanstormdotcom\Helloworld\Helper\Data.php**
<?php
class Alanstormdotcom_Helloworld_Helper_Data extends Mage_Core_Helper_Abstract
{
} 

**Alanstormdotcom\Helloworld\etc\system.xml**
<?xml version="1.0"?>
<config>    
    <tabs>
        <helloconfig translate="label" module="helloworld">
                <label>Hello Config</label>
                <sort_order>99999</sort_order>
        </helloconfig>  
    </tabs> 
</config>


**Alanstormdotcom\Helloworld\etc\config.xml**
<?xml version="1.0"?>
<config>    
    <modules>
        <Alanstormdotcom_Helloworld>
            <version>0.1.0</version>
        </Alanstormdotcom_Helloworld>
    </modules>
<frontend>
        <routers>
            <helloworld>
                <use>standard</use>
                <args>
                    <module>Alanstormdotcom_Helloworld</module>
                    <frontName>helloworld</frontName>
                </args>
            </helloworld>
        </routers>
    </frontend>
    <global>
      <helpers>
         <class>Alanstormdotcom_Helloworld_Helper</class>
      </helpers>    
    </global>
</config> 
Run Code Online (Sandbox Code Playgroud)

我只是想学习..我知道这适用于你,但仍然帮助我找到原因......我可能会想念

东西..谢谢.

configuration system helper magento

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

用于连接的Lambda表达式

public class CourseDetail
    {
        public CourseDetail();
        public string CourseId { get; set; }
        public string CourseDescription { get; set; }
        public long CourseSer { get; set; }
    }

 public class RefUIDByCourse
    {
        public long CourseSer {  get;  set; }
        public double DeliveredDose{ get; set; }
        public double PlannedDose{ get; set; }
        public string RefUID {  get;  set; }
     }
 public class RefData
    {
       public double DailyDoseLimit {  get;  set; }
       public string RefName {  get;  set; }
       public string RefUID …
Run Code Online (Sandbox Code Playgroud)

c# lambda linq-to-objects

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

Visual C++ 2010,rvalue参考错误?

它是Visual C++ 2010中的错误还是正确的行为?

template<class T>
T f(T const &r)
{
    return r;
}

template<class T>
T f(T &&r)
{
    static_assert(false, "no way"); //< line # 10
    return r;
}

int main()
{
    int y = 4;
    f(y); //< line # 17
}
Run Code Online (Sandbox Code Playgroud)

我想,函数f(T &&)永远不应该被调用,但是用T = int&调用它.输出:

    main.cpp(10): error C2338: no way
          main.cpp(17) : see reference to function template instantiation 'T f(T)' being compiled
          with
          [
              T=int &
          ]

更新1您是否知道任何C++ x0编译器作为参考?我已经尝试了在线测试驱动但无法编译r值参考.

更新2解决方法(使用SFINAE):

#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_reference.hpp>

template<class T>
T …
Run Code Online (Sandbox Code Playgroud)

c++ rvalue-reference visual-c++ visual-c++-2010 c++11

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

与Java Encapsulation Concept混淆

美好的一天!

我正在阅读一本关于封装的Java书,它提到了getter和setter方法.

我已经读过要隐藏属性,我必须将我的实例变量标记为"PRIVATE"并使用"PUBLIC"方法getter and setter来访问数据.所以我尝试制作一个类似但不是传统的代码,如下所示:

public class AddressBookEntry {

    private String name;
    private String address;
    private String telNo;
    private String email;

    public void getAllInfo() {
        name = JOptionPane.showInputDialog("Enter Name: ");
        address = JOptionPane.showInputDialog("Enter Address: ");
        telNo = JOptionPane.showInputDialog("Enter Tel. No: ");
        email = JOptionPane.showInputDialog("Enter Email Address: ");
    }
}
Run Code Online (Sandbox Code Playgroud)

上面的代码是否暴露了我的变量,因为我直接分配了它?我怎么能做得更好?如果我getter and setter改为使用传统方法并将值分配给其他类,会不会更好?"隐藏数据"是什么意思?

谢谢.

java encapsulation getter-setter

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

为什么我的线程Perl脚本会出现段错误?

我正在编写一个curses脚本,它需要在处理SIGINT后进行清理,以便将终端恢复到原始状态.

启用信号处理程序时,我得到一个段错误.

为了支持,我删除了所有的curses代码以解决问题.

码:

#!/usr/bin/env perl

use strict;
use warnings;
use threads;

sub cleanup { exit 0; }

sub run { while (1) {} }

# comment this line and the problem disappears
$SIG{INT} = \&cleanup;

foreach my $i (1..100) {
    print "Creating this thread\n";

    my $t = threads->create(\&run);

    print "Created that thread\n";
}

while (1) { print "Looping\n"; }
Run Code Online (Sandbox Code Playgroud)

示例错误跟踪(90%的时间段为segfaults):

$ ./threadtest.perl

...

Creating this thread
Creating that thread
Detaching this thread
Detaching that thread
Creating this thread
^CSegmentation …
Run Code Online (Sandbox Code Playgroud)

linux perl multithreading segmentation-fault

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

Mathematica 表达式开头的非交换乘法和负系数

在这篇文章中一些非常友善的 stackoverflow 贡献者的帮助下,我NonCommutativeMultiply (**)在 Mathematica 中 得到了以下新定义:

Unprotect[NonCommutativeMultiply];
ClearAll[NonCommutativeMultiply]
NonCommutativeMultiply[] := 1
NonCommutativeMultiply[___, 0, ___] := 0
NonCommutativeMultiply[a___, 1, b___] := a ** b
NonCommutativeMultiply[a___, i_Integer, b___] := i*a ** b
NonCommutativeMultiply[a_] := a
c___ ** Subscript[a_, i_] ** Subscript[b_, j_] ** d___ /; i > j :=
c ** Subscript[b, j] ** Subscript[a, i] ** d
SetAttributes[NonCommutativeMultiply, {OneIdentity, Flat}]
Protect[NonCommutativeMultiply];

这种乘法很棒,但是,它不处理表达式开头的负值,即
a**b**c + (-q)**c**a
应该简化为
a**b**c - q**c**a
,但不会。

在我的乘法中,变量q(以及任何整数定标器)是可交换的;我仍在尝试编写一个SetCommutative函数,但没有成功。我并不迫切需要SetCommutative,这会很好。 …

wolfram-mathematica

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

Rails - 使用form_for和fields_for,如何在fields_for块中访问子对象?

在我的第一个rails应用程序中,我正在尝试使用form_forfields_for创建嵌套对象表单.到目前为止一直很好,但我无法弄清楚如何在fields_for块中访问子对象.我已经在子对象中预先填充了一个字段,其中包含我想在用户指令中显示的数据.

车库模型
:

has_many :cars, :dependent => :destroy         
accepts_nested_attributes_for :cars
Run Code Online (Sandbox Code Playgroud)

汽车:

belongs_to :garage
Run Code Online (Sandbox Code Playgroud)

车库控制器

def new
  @garage = Garage.new
  for i in 1..5 
    @garage.cars.build :stall_number => i
  end
end
Run Code Online (Sandbox Code Playgroud)

_form.html.erb

<%= form_for @garage do |f| %>
  <%= f.label :title, "Garage Name" %><br />
  <%= f.text_field :title %>
  <% f.fields_for :cars do |builder| %>
    <p>Enter license for car parked in stall: <%= car.stall_number %></p>
    <%= f.label :license, "License #:" %><br />
    <%= f.text_field :license …
Run Code Online (Sandbox Code Playgroud)

forms nested-forms ruby-on-rails-3

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

我在哪里可以使用MS Powerpacks 10?

我无法找到网站在哪里下载ms Powerpacks 10,我在vb.net 2010中使用它.

vb.net powerpacks

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