小编Luk*_*vin的帖子

WPF与用户控件的数据绑定

我有一个wpf用户控件,它公开了一个自定义依赖项属性.在用户控件内,文本块绑定到dp的值.此数据绑定适用于所有方案,除非数据源是对象.

重现这个的最小代码是:

这是用户控件的主要部分

<StackPanel Orientation="Horizontal">
    <TextBlock Text="**SimpleUC** UCValue: "/>
    <TextBlock Text="{Binding UCValue}"/>
</StackPanel>
Run Code Online (Sandbox Code Playgroud)

以及后面的用户控制代码:

    public SimpleUC()
    {
        InitializeComponent();
        this.DataContext = this;
    }

    public string UCValue
    {
        get { return (string)GetValue(UCValueProperty); }
        set { SetValue(UCValueProperty, value); }
    }

    public static readonly DependencyProperty UCValueProperty =
        DependencyProperty.Register("UCValue", typeof(string), typeof(SimpleUC), new UIPropertyMetadata("value not set"));
Run Code Online (Sandbox Code Playgroud)

这是测试窗口.我将项目xml命名空间导入为"custom"

<Window.Resources>
    <Style TargetType="{x:Type StackPanel}">
        <Setter Property="Margin" Value="20"/>
    </Style>
</Window.Resources>
<StackPanel>
    <StackPanel>
        <TextBlock Text="This fails to bind:"/>
        <custom:SimpleUC UCValue="{Binding SomeData}"/> 
    </StackPanel>
    <StackPanel>
        <TextBlock>The same binding on a regular control like …
Run Code Online (Sandbox Code Playgroud)

data-binding wpf user-controls

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

Emacs压痕难度

我真的想切换到emacs,但学习设置环境真的很痛苦.每个人都说它值得,所以我继续说.

我希望我的c代码以这种方式实现:

if(asdf)
{
    asdr = 1;
}
Run Code Online (Sandbox Code Playgroud)

根据当前的标准(我知道,不要让我开始),可能是:

if(asdf) {
    asdr = 1;
}
Run Code Online (Sandbox Code Playgroud)

我似乎无法将缩进大小从2更改,它总是看起来像GNU标准:

if(asdf)
  {
    asdr = 1;
  }
Run Code Online (Sandbox Code Playgroud)

,我不喜欢.这是我在.emacs中添加的内容:

; Warn in C for while();, if(x=0), ...
(global-cwarn-mode 1)

; no electric mode in c
(c-toggle-electric-state -1)
; indent the current line only if the cursor is at the beginning of the line
(setq-default c-tab-always-indent nil)
(setq-default c-indent-level 4)
(setq-default tab-width 4)
(setq-default indent-tabs-mode nil)
(setq-default c-basic-offset 4)
(setq-default c-basic-indent 4)
; These commands I read …
Run Code Online (Sandbox Code Playgroud)

emacs indentation

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

WCF安全认证

我有一个简单的服务,我尝试设置身份验证.在客户端上,我希望用户输入他们的Windows用户帐户.WCF将使用客户端提供的用户名/密码,并根据Windows身份验证对其进行身份验证.

这是我的服务器app.config

 <system.serviceModel>
    <services>
      <service name="WcfService.Service1" behaviorConfiguration="WcfService.Service1Behavior">
        <host>
          <baseAddresses>
            <add baseAddress = "http://localhost:8731/Design_Time_Addresses/WcfService/Service1/" />
          </baseAddresses>
        </host>
        <endpoint address ="" binding="wsHttpBinding" contract="WcfService.IService1">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="WcfService.Service1Behavior">
          <serviceMetadata httpGetEnabled="True"/>
          <serviceDebug includeExceptionDetailInFaults="True" />

          <serviceCredentials>
            <userNameAuthentication userNamePasswordValidationMode = "Windows"/>
          </serviceCredentials>

        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
Run Code Online (Sandbox Code Playgroud)

这是我的客户端app.config

<system.serviceModel>
    <bindings>
        <wsHttpBinding>
          <binding name="WSHttpBinding_IService1">

              <security mode = "Message">
                <message  clientCredentialType = "UserName"/>
              </security>

            </binding>
        </wsHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://localhost:8731/Design_Time_Addresses/WcfService/Service1/"
            binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService1"
            contract="ServiceReference1.IService1" name="WSHttpBinding_IService1">
            <identity>
                <dns value="localhost" /> …
Run Code Online (Sandbox Code Playgroud)

.net c# wcf-security

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

SQL连接:SQL ANSI标准的未来(vs加入)?

我们正在开发ETL工作,我们的顾问在连接表时一直使用"旧式"SQL

select a.attr1, b.attr1
from table1 a, table2 b
where a.attr2 = b.attr2
Run Code Online (Sandbox Code Playgroud)

而不是使用内部连接子句

select a.attr1, b.attr1
from table1 as a inner join table2 as b
   on a.attr2 = b.attr2
Run Code Online (Sandbox Code Playgroud)

我的问题是,从长远来看,是否有使用旧"加入"的风险?这种连接支持多长时间并保持为ANSI标准?我们的平台是SQL Server,我的主要原因是将来不再支持这些"where join".发生这种情况时,我们必须使用"内连接"连接方式修改所有ETL作业.

sql sql-server join ansi-sql sql-server-2008

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

如何在mercurial中回滚到已提交和推送的修订?

我犯了一个错误并删除了一个文件.我想回到我之前的承诺!我尝试了恢复和退出,没有运气......

有提示吗?

编辑:我这样做了:

hg forget file
hg commit -m "Blah"
hg push

最后一次推送的修订号是17.

现在不再跟踪文件了.我想将它恢复到第15版(不是之前的版本,而是一个额外的退步)因为我不想继续使用rev 16中的文件.

mercurial restore commit

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

Reactive Extensions(Rx)是否会取代任务并行库?

在仔细阅读了Rx.NET的样本后,我对于Reactive Extensions的概念和实现有多么精彩.它似乎为开发人员提供了一种更易于维护的模式,用于实现.NET 4.0的任务并行库提供的相同类型的多线程并行编码.

Rx.NET会取代TPL吗?应该是?

.net parallel-processing system.reactive

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

适用于Java的智能日期/时间解析器

是否有一些适用于Java的智能日期/时间解析器库?智能我的意思是,我不需要指定日期/时间格式.API应该类似于:

Calendar cal = DateTimeParser.parse("01/06/10 14:55");
cal = DateTimeParser.parse("1 Jan 2009"); // assumes 00:00 time
cal = DateTimeParser.parse("1.2.2010");
cal = DateTimeParser.parse("kygyutrtf"); // throws exception
Run Code Online (Sandbox Code Playgroud)

更新:

// I'm telling the parser: "If unsure, assume US date format"
cal = DateTimeParser.parse("01/02/03", new Locale("en-us"));
Run Code Online (Sandbox Code Playgroud)

java datetime

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

如何在命令行中使用Emacs启动不同的模式?

有没有办法使用命令行启动不同的emacs模式?例如,是否可以按如下方式运行emacs?

   emacs --org-mode # to start orgmode
   emacs --python-mode # to start python mode
Run Code Online (Sandbox Code Playgroud)

之后我可以运行emacs来输入'Mx org-mode',但我想知道我是否可以启动不同的模式.

emacs mode

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

在进行性能测试时如何避免SQL Server的"重建统计"?

这些天我正在做一些SQL调优,并在测试期间找到一个奇怪的SQL:

SELECT StatMan([SC0],[SC1], [SB0000]) 
FROM (SELECT TOP 100 PERCENT [SC0],[SC1], step_direction([SC0]) over (order by NULL) AS [SB0000]  
      FROM (SELECT [tableA] AS [SC0],[tableB] AS [SC1] 
            FROM [dbo].[url] WITH (READUNCOMMITTED,SAMPLE 3.408654e+000 PERCENT) 
           ) AS _MS_UPDSTATS_TBL_HELPER 
     ORDER BY [SC0],[SC1], [SB0000] 
    ) AS _MS_UPDSTATS_TBL  
OPTION (MAXDOP 1)
Run Code Online (Sandbox Code Playgroud)

看起来这是根据SQL Server做一些"reindex"或"重建"一些db索引.但我的问题是,除了测试之前每个表的"reindex"之外,我们如何在长负载测试期间避免这种情况.

由于我的表包含足够的行,因此该SQL将消耗16862ms.我的测试中有很多插入动作.

sql sql-server testing performance

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

在Emacs的eshell中使用RVM

在emacs的eshell中使用RVM,我无法设置ruby版本.为什么?环境:Ubuntu 9.10

/media/Work/rubyworkspace $ ruby -v 
ruby 1.8.7 (2009-06-12 patchlevel 174) [i486-linux]
/media/Work/rubyworkspace $ rvm use 1.9.2
Using /usr/local/rvm/gems/ruby-1.9.2-p180
/media/Work/rubyworkspace $ ruby -v
ruby 1.8.7 (2009-06-12 patchlevel 174) [i486-linux]
Run Code Online (Sandbox Code Playgroud)

ruby emacs ubuntu eshell rvm

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