我想在WPF Expander Header上应用一种样式.在下面的XAML中,我有一个Expander,但它的风格不仅适用于标题.
谢谢.
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="640"
>
<StackPanel>
<StackPanel.Resources>
<Style TargetType="Expander">
<Style.Resources>
<LinearGradientBrush x:Key="BackBrush" StartPoint="0.5,0" EndPoint="0.5,1">
<GradientStop Color="#EF3132" Offset="0.1" />
<GradientStop Color="#D62B2B" Offset="0.9" />
</LinearGradientBrush>
</Style.Resources>
<Setter Property="Background" Value="{StaticResource BackBrush}"/>
</Style>
</StackPanel.Resources>
<Expander>
<StackPanel>
<TextBlock>Bike</TextBlock>
<TextBlock>Car</TextBlock>
<TextBlock>Truck</TextBlock>
</StackPanel>
</Expander>
</StackPanel>
</Page>
Run Code Online (Sandbox Code Playgroud) 我发现一个问题似乎总是在IE8中打开一段html和javascript时重现.
<html>
<body>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
$(window).resize(function() {
console.log('Handler for .resize() called');
});
});
</script>
<div id="log">
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
在IE8中加载此文件并打开开发人员工具将显示在重新调整浏览器窗口大小后连续打印日志消息.
有谁知道为什么?这不是在IE7或IE9中发生的,也不是在其他浏览器中(或至少是其最新版本).
UPDATE
防止resize()的连续触发的一个解决方案是在document.body.onresize上添加处理程序(如果浏览器是IE8).
var ieVersion = getInternetExplorerVersion();
if (ieVersion == 8) {
document.body.onresize = function () {
};
}
else {
$(window).resize(function () {
});
}
Run Code Online (Sandbox Code Playgroud)
但这并没有回答我的问题:是否继续触发resize()IE8中的错误?
我正在使用.NET Windows窗体DataGridView,我需要编辑一个DataBound列(绑定在布尔DataTable列上).为此,我指定像这样的单元格模板:
DataGridViewColumn column = new DataGridViewColumn(new DataGridViewCheckBoxCell());
你看我需要一个CheckBox单元格模板.
我面临的问题是该列始终是只读/禁用的,就好像它是TextBox类型一样.它根本不显示复选框.
有关如何使用DataGridView的可编辑复选框列的任何想法?
更新:对于Windows窗体,请.
谢谢.
StackOverflow用户jolson有一段很好的代码,它举例说明了如何在不使用字符串的情况下注册menthods,而是在这里表达树.
是否可以为属性而不是方法提供类似的东西?传递属性(不是属性的名称)并在方法内部获取属性名称?
像这样的东西:
RegisterMethod(p => p.Name)
void RegisterMethod(Expression??? propertyExpression) where T : Property ???
{
string propName = propertyExpression.Name;
}
Run Code Online (Sandbox Code Playgroud)
谢谢.
我正在开发.NET 3.5 Windows窗体应用程序.我有两个项目,UI和图书馆.
UI使用强类型设置,通常存储在app.config文件中.我使用UI.Properties.Settings类(由Visual Studio生成)读取它们.
库使用自己的强类型设置(转储到Library.config文件中的Settings.settings文件).
在运行时,库设置不会从Library.config文件重新加载.运行时只读取UI.config文件.所以我在库程序集中遇到默认设置,并且在部署后无法提供值.
总结一下:对于不是主可执行文件的应用程序程序集,在程序集加载时不会读取设置.
我知道我可以使用ConfigurationManager.AppSettings ["value"],这将从默认的应用程序配置文件(UI.config)中读取,但如果我想要强类型设置(使用Properties.Settings类读取),我该怎么办?
打电话Library.Properties.Settings.Default.Reload()
不会这样做.
谢谢.
我有这样的[Flags]枚举:
[Flags]
public enum Status
{
None = 0,
Active = 1,
Inactive = 2,
Unknown = 4
}
Run Code Online (Sandbox Code Playgroud)
状态枚举可能包含两个值,例如:
Status s = Status.Active | Status.Unknown;
Run Code Online (Sandbox Code Playgroud)
现在我需要创建一个linq查询(LINQ to ADO.NET Entities)并询问状态为s的记录,即Active或Unknown;
var result = from r in db.Records
select r
where (r.Status & (byte)s) == r.Status
Run Code Online (Sandbox Code Playgroud)
当然我得到一个错误,因为LINQ to Entities只知道在Where子句中处理原始类型.
错误是:
无法创建"闭包类型"类型的常量值.在此上下文中仅支持原始类型(例如Int32,String和Guid').
有可行的方法吗?我可能有一个状态枚举,有10个可能的值,并查询5个状态.如何以优雅的方式使用Flags枚举构造查询?
谢谢.
更新
这似乎是一个Linq to Entities问题.我认为在LINQ to SQL中它可以工作(不确定,没有经过测试).
.net ×3
c# ×2
app-config ×1
datagridview ×1
enums ×1
expander ×1
flags ×1
header ×1
html ×1
javascript ×1
jquery ×1
linq ×1
properties ×1
resize ×1
settings ×1
styles ×1
winforms ×1
wpf ×1