小编The*_*der的帖子

对象摘要中的NewLine

问候

为属性/字段/方法等设置摘要时,是否可以在其中添加换行符?

/// <summary>
/// This is line 1
/// This is line 2
/// </summary>
public bool TestLine { get; set; }
Run Code Online (Sandbox Code Playgroud)

当我设置它时,它显示为鼠标悬停:

bool TestLine
This is line 1 This is line 2
Run Code Online (Sandbox Code Playgroud)

但我希望它显示为:

bool TestLine
This is line 1 
This is line 2
Run Code Online (Sandbox Code Playgroud)

我尝试过使用\n但不起作用.有没有办法完成这项工作?

c# newline summary

91
推荐指数
6
解决办法
3万
查看次数

确定类型是否为字典

如何判断Type是否为 Dictionary<,>

目前唯一对我有用的是我真的知道这些论点.

例如:

var dict = new Dictionary<string, object>();
var isDict = dict.GetType() == typeof(Dictionary<string, object>; // This Works
var isDict = dict.GetType() == typeof(Dictionary<,>; // This does not work
Run Code Online (Sandbox Code Playgroud)

但字典并不总是<string, object>如此,如何在不知道参数的情况下检查它是否是字典而不必检查名称(因为我们还有其他包含该字的类Dictionary.

c# generics dictionary

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

如果绑定为null,则隐藏工具提示

目前我有以下代码来显示工具提示.

<Border BorderBrush="Black"
        BorderThickness="{Binding Border}"
        Height="23"
        Background="{Binding Color}">
<ToolTipService.ToolTip>
    <TextBlock Text="{Binding TooltipInformation}" />
</ToolTipService.ToolTip>
Run Code Online (Sandbox Code Playgroud)

这在ItemsControl中显示,包含大约25个项目.其中只有少数的值设置为TooltipInformation

如果TooltipInforation是一个空字符串,它仍然显示包含文本块的工具提示框作为一个非常小的窗口(大约5px高和20px宽).即使我将文本块可见性设置为折叠.

如果TooltipInformation的值为null或空字符串,有没有办法完全删除工具提示?

c# silverlight xaml binding tooltip

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

设置TabPage标题颜色

问候,

我有一个标签控件,我希望其中一个标签在事件中更改了文本颜色.我找到了像C# - TabPage Color事件C#Winform这样的答案:如何设置TabControl的基色(不是标签页), 但使用这些设置所有颜色而不是一个.

所以我希望有一种方法可以通过我想改变的方法来实现这个方法而不是事件?

就像是:

public void SetTabPageHeaderColor(TabPage page, Color color) 
{
    //Text Here
}
Run Code Online (Sandbox Code Playgroud)

c# tabcontrol header colors winforms

27
推荐指数
3
解决办法
6万
查看次数

使用form.serialize获取正确的复选框值

我们目前正在使用$('form').serialize()获取所有表单信息

这会将任何复选框值返回为"开"或"关".

有没有办法使用同样的方法获得1/0或真/假值?

javascript jquery serialization

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

为什么没有文化枚举?

问候,

我想知道为什么C#中的文化没有预先设定的枚举?由于文化永远不会改变,并且总是像"nl-NL,en-GB,en-US"..为什么不为它做一个简单的事情让事情变得有点容易?

[编辑]

如上所述,文化会发生变化......但不是全部.为什么不制作一个包含所有文化并允许添加/更改它们的枚举/类类型?

c# cultureinfo

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

Datagrid MVVM滚动到视图中

问候,

我已设法使用http://www.codeproject.com/Tips/125583/ScrollIntoView-for-a havenGrid-when- using- MVVM.aspx 滚动到所选项目,但这只会滚动直到它到达所选项目项目.

我希望所选项目显示在datagrid的TOP,目前它显示在datagrid的底部.

有没有办法实现这个目标?

c# silverlight datagrid mvvm

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

带有超链接的WPF Resources.resx字符串?

我想要一个字符串资源,其中包含一个超链接.我想这是不可能的,除非我有4个资源字符串:

预超链接文本超链接href超链接文本超链接后文本.

然后通过以下方式在xaml中构建它:

<StackPanel Grid.Column="1" Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Right">
    <TextBlock Grid.Column="1" Text="{x:Static p.Resources.PreHText}" />
    <Hyperlink Grid.Column="1" NavigateUri="{x:Static p.Resources.HHref}">
    <TextBlock Text="{x:Static p.Resources.HText}" /></Hyperlink></TextBlock>
    <TextBlock Grid.Column="1" Text="{x:Static p.Resource.PostHText}" />
</StackPanel>
Run Code Online (Sandbox Code Playgroud)

由于许多原因(造型,不是非常动态等等),这很可怕.栏创建我自己的渲染和字符串格式,例如"请发送电子邮件至{me@there.com |帮助台}以获得进一步的帮助".有没有其他方法来实现这一目标?(不必使用resources.resx文件)

c# wpf xaml

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

创建淡出标签

这似乎是一个简单的问题......

我正在寻找C#Winforms中的Label.Opacity属性.

我想做的是有一种逐渐消失标签的方法.通过计时器或许?

由于没有Opacity我试图将它的transperency设置为更高的数字,直到它足够高,该项目应该是不可见的.但我似乎无法做到这一点.

目前我有:

public FadeLabel()
{
    MyTimer timer = new MyTimer();
    this.TextChanged += (s, ea) =>
    {
        if (timer.IsActive)
        {
            timer.Reset();
        }
        else
        {
            timer.WaitTime.Miliseconds = 500;
            timer.Start();
            timer.Completed += (a) =>
            {
                int i = 0;
                Timer tm = new Timer();
                tm.Interval = 1;
                tm.Tick += (sa, aea) =>
                {
                    i++;
                    this.ForeColor = Color.FromArgb(i, Color.Black);
                    this.BackColor = Color.FromArgb(i, Color.White);
                    this.Invalidate();
                    if (i == 255)
                    {
                        tm.Stop();
                    }
                };
                tm.Start();
            };
        }
    };
}
Run Code Online (Sandbox Code Playgroud)

c# label opacity fadeout winforms

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

缺少Style.Triggers和x:类型.为什么?

<TextBlock Text="{Binding MyTextProperty}">
    <TextBlock.Style>
        <Style TargetType="{x:Type TextBox}">
            <Style.Triggers>
                <DataTrigger Binding="{Binding MyTextProperty}" Value="{x:Null}">
                    <Setter Property="Text" Value="Hey, the text should not be empty!" />
                    <Setter Property="Foreground" Value="Red" />
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </TextBlock.Style>
</TextBlock>
Run Code Online (Sandbox Code Playgroud)

问题1:为什么要<Style TargetType="{x:Type TextBox}">给出错误The type 'x:Type' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.

问题2:为什么我收到错误 The attachable property 'Triggers' was not found in type 'Style'.

我错过了什么吗?

silverlight xaml triggers

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