小编dig*_*ire的帖子

删除所有DataGrid行和单元格边框

我想隐藏(或删除)我的数据网格中所有行(以及随后的单元格)的所有边框,想一个基本的HTML表.我看了一遍,大多数问题似乎是关于造型而不是隐藏它们.

我已经尝试过像这样设置BorderBrush和BorderThickness:

 <DataGrid.RowStyle>
     <Style TargetType="DataGridRow">
         <Setter Property="BorderBrush" Value="Transparent" />
         <Setter Property="BorderThickness" Value="0" />
     </Style>
  </DataGrid.RowStyle>
Run Code Online (Sandbox Code Playgroud)

为CellStyle尝试了相同,但没有骰子,仍然看到边界.

.net c# wpf xaml datagrid

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

为什么解除引用运算符(*)也用于声明指针?

我不确定这是否是一个正确的编程问题,但它总是困扰我,我想知道我是否是唯一的.

在最初学习C++时,我理解了引用的概念,但指针让我感到困惑.你为什么问?因为你如何声明一个指针.

考虑以下:

void foo(int* bar)
{
}


int main()
{
    int x = 5;
    int* y = NULL;

    y = &x;
    *y = 15;     
    foo(y);

}
Run Code Online (Sandbox Code Playgroud)

该函数foo(int*)int指针作为参数.由于我已经声明yint指针,我可以传递yfoo,但是当我第一次学习C++时,我将*符号与解除引用相关联,因此我认为int需要传递一个解引用.我会试图通过*y进入foo,这显然是行不通的.

用一个单独的运算符来声明指针会不会更容易?(或用于解除引用).例如:

void test(int@ x)
{
}
Run Code Online (Sandbox Code Playgroud)

c++ syntax pointers notation dereference

53
推荐指数
6
解决办法
6195
查看次数

"阻止"直到满足某些条件的最佳方法

我想创建一些以通用方式使用的方法,它是否会阻塞(除非某个超时到期),直到满足给定条件.

代码中的用法类似于:

WaitUntil( condition );
Run Code Online (Sandbox Code Playgroud)

我尝试使用While(..)循环实现它,但这似乎是浪费.

在当前的实现中,我正在初始化一个在TIMEOUT到期的"一次性"计时器.我正在运行一个while循环,并检查计时器是否已超时,如果有,则抛出异常.

有没有简单而有效的技术来实现这种方法?

.net c# blocking

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

保持你的javascript结构和整洁(作为OO程序员)

我最近一直在玩javascript,HTML5,chrome扩展,jQuery以及所有好东西.到目前为止,我对javascript的可能性印象深刻,我唯一挣扎的是构造我的代码并保持整洁.在我知道之前,功能遍布整个地方.我总是以面向对象的方式(C++和C#)完成我的编程,我发现自己无法保持整洁.感觉就像我总是最终得到一堆静态的util函数,我是否在C#中"思考".

我一直在寻找关于javascript中对象的一些信息,但它似乎归结为在函数中包装函数.这是构建代码库的好方法吗?从表面上看,它看起来有些神圣.或者还有其他方法可以保持OO心态的整洁吗?

javascript oop

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

如何在UserControl中使用TwoWay绑定?

我有自己的UserControl,LabeledTextBox它是a Label和a..well 的组合,TextBox.此控制具有两个属性:Caption这将被绑定到的标题Label,和Value将被绑定到TextTextBox.

码:

public class LabeledTextBox : Control
{
    static LabeledTextBox()
    {
        DefaultStyleKeyProperty.OverrideMetadata(typeof(LabeledTextBox), new FrameworkPropertyMetadata(typeof(LabeledTextBox)));
    }

    public string Caption
    {
        get { return (string)GetValue(CaptionProperty); }
        set { SetValue(CaptionProperty, value); }
    }

    // Using a DependencyProperty as the backing store for Caption.  This enables animation, styling, binding, etc...
    public static readonly DependencyProperty CaptionProperty =
        DependencyProperty.Register("Caption", typeof(string), typeof(LabeledTextBox), new UIPropertyMetadata(""));


    public string Value
    {
        get { …
Run Code Online (Sandbox Code Playgroud)

data-binding wpf user-controls controltemplate

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

UserNamePasswordValidator可以抛出除MessageSecurityException以外的任何内容吗?

我通过web.config连接了一个带有UserNamePasswordValidator的WCF服务,没问题.在我的验证器中,我重写Validate,检查凭据并在必要时抛出FaultException.

例:

public class CredentialValidator : UserNamePasswordValidator
{
    public override void Validate(string userName, string password)
    {
        if (userName != "dummy")
        {
            throw new FaultException<AuthenticationFault>(new AuthenticationFault(), "Invalid credentials supplied");
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

如果我在.NET应用程序中自己使用此服务并提供无效凭据,则会抛出MessageSecurityException并显示以下消息:

"从另一方收到了一个不安全或不正确安全的故障.请参阅内部FaultException以获取故障代码和详细信息."

我预期的FaultException是MessageSecurityException的InnerException.

有没有办法让客户端只接收FaultException?

MessageSecurityException并不特别描述异常的真正原因(对SO的快速搜索会产生各种问题,包括服务器/客户端时间同步......),并且由于第三方将使用该服务,我希望尽可能清楚.

c# authentication validation wcf fault

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