问候
为属性/字段/方法等设置摘要时,是否可以在其中添加换行符?
/// <summary>
/// This is line 1
/// This is line 2
/// </summary>
public bool TestLine { get; set; }
Run Code Online (Sandbox Code Playgroud)
当我设置它时,它显示为鼠标悬停:
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
我尝试过使用\n但不起作用.有没有办法完成这项工作?
如何判断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.
目前我有以下代码来显示工具提示.
<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# - TabPage Color事件 和C#Winform这样的答案:如何设置TabControl的基色(不是标签页), 但使用这些设置所有颜色而不是一个.
所以我希望有一种方法可以通过我想改变的方法来实现这个方法而不是事件?
就像是:
public void SetTabPageHeaderColor(TabPage page, Color color)
{
//Text Here
}
Run Code Online (Sandbox Code Playgroud) 我们目前正在使用$('form').serialize()获取所有表单信息
这会将任何复选框值返回为"开"或"关".
有没有办法使用同样的方法获得1/0或真/假值?
问候,
我想知道为什么C#中的文化没有预先设定的枚举?由于文化永远不会改变,并且总是像"nl-NL,en-GB,en-US"..为什么不为它做一个简单的事情让事情变得有点容易?
[编辑]
如上所述,文化会发生变化......但不是全部.为什么不制作一个包含所有文化并允许添加/更改它们的枚举/类类型?
问候,
我已设法使用http://www.codeproject.com/Tips/125583/ScrollIntoView-for-a havenGrid-when- using- MVVM.aspx 滚动到所选项目,但这只会滚动直到它到达所选项目项目.
我希望所选项目显示在datagrid的TOP,目前它显示在datagrid的底部.
有没有办法实现这个目标?
我想要一个字符串资源,其中包含一个超链接.我想这是不可能的,除非我有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#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) <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'.
我错过了什么吗?
c# ×8
silverlight ×3
xaml ×3
winforms ×2
binding ×1
colors ×1
cultureinfo ×1
datagrid ×1
dictionary ×1
fadeout ×1
generics ×1
header ×1
javascript ×1
jquery ×1
label ×1
mvvm ×1
newline ×1
opacity ×1
summary ×1
tabcontrol ×1
tooltip ×1
triggers ×1
wpf ×1