我试图将所选ListBoxItem的背景颜色设置为白色而不是系统颜色.我已经阅读了我在这里可以找到的内容并且已经跟随或者相信已经遵循了那里的建议(更改所选ListBox项目的背景颜色,WPF如何在列表框失去焦点时更改列表框所选项目文本颜色,更改选中和不专心的列表框样式不会变灰,以及其他).
所有似乎都通过将HighlightBrush和ControlBrush设置为所选项目的透明来解决问题.我有以下XAML并且它正确设置了字体颜色,但无论画笔设置如何,backgroound都是默认的透明蓝色.我仍然是一个WPF菜鸟,所以我必须在这里遗漏一些简单的东西.
<ListBox Width="Auto" Height="Auto" Grid.Column="0" BorderThickness="0" Background="#FFF3F3F3" xmlns:sys="clr-namespace:System;assembly=mscorlib">
<ListBox.ItemsSource>
<x:Array Type="{x:Type sys:String}">
<sys:String>String 1</sys:String>
<sys:String>String 2</sys:String>
<sys:String>String 3</sys:String>
<sys:String>String 4</sys:String>
</x:Array>
</ListBox.ItemsSource>
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem" BasedOn="{StaticResource {x:Type ListBoxItem}}">
<Style.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent" />
<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent" />
</Style.Resources>
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="FontSize" Value="16"/>
<Setter Property="Foreground" Value="#999999"/>
<Style.Triggers>
<Trigger Property="IsSelected" Value="True" >
<Setter Property="Background" Value="White" />
<Setter Property="Foreground" Value="Black" />
</Trigger>
</Style.Triggers>
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" HorizontalAlignment="Right" Margin="0,0,8,0" …Run Code Online (Sandbox Code Playgroud) 我实现了文件的gzip/zlib解压缩,如增强网站上的示例所示.
void CompressionUtils::Inflate(std::ifstream& inputFile,
std::ofstream& outputFile)
{
boost::iostreams::filtering_streambuf<boost::iostreams::input> in;
in.push(boost::iostreams::gzip_decompressor());
in.push(inputFile);
boost::iostreams::copy(in, outputFile);
}
Run Code Online (Sandbox Code Playgroud)
这很好用.我也是从一个套接字读取数据,我从一个基于休息的JSON服务获得了这个数据.我想我会写一个基于内存的实现,这有多难.好吧,我发现我不理解流和流缓冲区.我责怪过去几年在Java;)..所以我开始走这条道路.
void CompressionUtils::Inflate(char* compressed,
int size,
char* decompressed)
{
boost::iostreams::stream<boost::iostreams::array_source> source(compressed,size);
//std::stringstream str;
boost::iostreams::filtering_streambuf<boost::iostreams::input> in;
in.push(boost::iostreams::gzip_decompressor());
in.push(source);
//boost::iostreams::copy(in, str);
}
Run Code Online (Sandbox Code Playgroud)
但我不知道我可以使用哪种流来基本上获得解char*压缩流的解压缩表示.这应该很容易,而且很可能是,但是我在过去的几个小时里一直在浪费不成功的尝试.
我最近开始在我正在做的java构建中使用findbugs静态分析工具.第一份报告带来了大量高优先级警告.作为一个迷恋型人,我已经准备好全力以赴.但是,我必须遗漏一些东西.在比较事情时,我得到了大部分警告.如下面的代码:
public void setSpacesPerLevel(int value)
{
if( value >= 0)
{
spacesPerLevel = value;
}
else
{
spacesPerLevel = 0;
}
}
Run Code Online (Sandbox Code Playgroud)
在读取的if语句中生成高优先级警告.
File:Indenter.java,Line:60,Type:BIT_AND_ZZ,Priority:High,Category:CORRECTNESS检查sample.Indenter.setSpacesPerLevel(int)中的((...)&0)== 0
我将int与int进行比较,看起来很常见.我通过类似的简单比较得到了相当多的错误.
对于看似简单的代码块,我有很多其他高优先级警告.我在这里错过了什么吗?我意识到静态分析会产生误报,但我所看到的错误似乎过于微不足道.
这个让我也摸不着头脑.
for(int spaces = 0;spaces < spacesPerLevel;spaces++)
{
result = result.concat(" ");
}
Run Code Online (Sandbox Code Playgroud)
这给出了以下findbugs警告:
File: Indenter.java, Line: 160, Type: IL_INFINITE_LOOP, Priority: High, Category: CORRECTNESS
There is an apparent infinite loop in sample.Indenter.indent()
This loop doesn't seem to have a way to terminate (other than by perhaps throwing an exception).
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
所以基本上我有一些文件和50-60个高优先级警告类似于上面的那些.我正在使用findbugs 1.3.9并从findbugs ant任务中调用它 …
我有一个自托管的WCF Rest服务,我用它来模拟我还没有访问权限的服务.(请参阅JSON REST服务:内容编码:gzip)我gziped我的响应,但没有找到在HTTP响应头中设置Content-Encoding的方法.有没有办法到达HTTP头对象,所以我可以设置这个字段?
对于应用程序配置,我经常会创建一个配置类,其中包含应用程序的配置值,然后将其反序列化为要使用的对象。配置对象通常与用户界面控件进行数据绑定,以便用户可以更改和保留配置。配置类通常具有分配给属性的默认值,以便始终存在默认配置。这效果很好。我最近遇到了一种情况,我有一个提供一些默认路径信息的字符串列表。我所看到的让我意识到我并不完全知道在 XML 反序列化到对象期间如何填充对象属性。
所以我创建了一个简单的示例来展示该行为。下面是一个简单的类,它有几个具有一些代码默认值的属性。
[Serializable]
public class TestConfiguration
{
public String Name
{
get
{
return mName;
}
set
{
mName = value;
}
}private String mName = "Pete Sebeck";
public List<String> Associates
{
get
{
return mAssociates;
}
set
{
mAssociates = value;
}
} private List<String> mAssociates = new List<string>() { "Jon", "Natalie" };
public override String ToString()
{
StringBuilder buffer = new StringBuilder();
buffer.AppendLine(String.Format("Name: {0}", Name));
buffer.AppendLine("Associates:");
foreach(String associate in mAssociates)
{
buffer.AppendLine(String.Format("\t{0}", associate));
}
return buffer.ToString(); …Run Code Online (Sandbox Code Playgroud) 我最近有机会创建一个新的基于棱镜的应用程序。我用6.3版本已经有一段时间了,但是看到prism 7已经退出预发布,想试一试。我使用 Prism 模板包创建了一个新的棱镜应用程序,并且一切都按预期开箱即用。我更新了视图模型,就像在 6.3 中通常做的那样,传入容器,这样我就可以解析一些稍后会向视图提供信息的对象,在 6.3 中,我将执行以下操作:
public MainWindowViewModel(IRegionManager aRegionManager,
IUnityContainer aUnityContainer) : base()
Run Code Online (Sandbox Code Playgroud)
现在在 7.1.0.431 中,我尝试做同样的事情,但更新了接口以考虑新的 IOC 抽象。
public MainWindowViewModel(IRegionManager aRegionManager,
IContainerProvider aContainerProvider,
IContainerRegistry aContainerRegistry) : base()
Run Code Online (Sandbox Code Playgroud)
这会从 ViewModelLocator.AutoWireViewModel 中为 IContainerX 参数生成一个异常。
System.Exception {Unity.Exceptions.ResolutionFailedException}
{"Resolution of the dependency failed, type = 'Sample.ViewModels.MainWindowViewModel', name = '(none)'.\nException occurred while: while resolving.\nException is: InvalidOperationException - The current type, Prism.Ioc.IContainerProvider, is an interface and cannot be constructed. Are you missing a type
Run Code Online (Sandbox Code Playgroud)
这就像我缺少一个引用,但我正在将该类型传递到应用程序的 RegisterTypes 调用中,因此应该找到所有引用。我对新的 7.X 版本做错了吗?
编辑:每@mnistic
这是模板包提供的 App.xaml.cs 中的代码,其中传入了 …
使用apache commonds bidimap时,如何处理同步。例如,如果我创建如下所示的地图
BidiMap oneWay = new DualHashBidiMap();
BidiMap theOtherWay = oneWay.inverseBidiMap();
因此,如果我要向上述变量之一添加/访问/删除键/值对,我需要同步两者(线程同步)。如果我需要这样做,似乎我不会通过使用 2 张地图实现此功能而获得任何好处。
感谢您花时间查看此问题。
我目前正在使用JBoss 5.1.0并部署了一个在远程系统上使用WebService的ejb.我最近收到了一个新的VM,它有一个更新的JBoss配置,现在在部署之后,当试图在webservice上调用一个方法时,我收到以下错误.
java.lang.ClassCastException:org.jboss.ws.core.soap.SOAPElementImpl无法强制转换为javax.xml.soap.SOAPHeader
我已经从WSDL生成了java Web服务绑定,并且它一直在工作.这里肯定会有一些类路径问题,但我不知道从哪里开始看.
-抢
看起来像picketlink库被添加到JBoss实例以获得webservice安全性,一些web服务部署在该本地实例上.我打电话的远程Web服务没有使用它.
在XAML绑定标记中可以否定布尔属性。不知道这是正确的描述。例如,我使用一个内置的转换器来基于其是否处于活动状态来设置窗口边框控件的可见性。
<Border BorderBrush="{StaticResource BorderColorBrush}"
BorderThickness="1"
Visibility="{Binding IsActive,
RelativeSource={RelativeSource FindAncestor,
AncestorType={x:Type Window}},
Converter={StaticResource bool2VisibilityConverter}}" />
Run Code Online (Sandbox Code Playgroud)
与我相反的是,如果Window处于活动状态,我希望将Visibility设置为false。这只是一个例子,但是我遇到了其他情况,在这种情况下可以应用“!” 转换为股票转换器正在评估的布尔属性,因此我不必编写自定义变量。
我正在为我们的实验室编写实用程序,用于根据NAS上的一组安装程序(msi文件)检查本地计算机上已安装的软件。通过一些网络搜索,似乎似乎可以从代码中确定基于Windows的计算机上安装了哪些软件包的首选方法是遍历HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall密钥。我感兴趣的安装程序具有名称空间(由我创建),因此选择我感兴趣的注册表项很容易,但是我注意到我使用wix创建的安装程序没有像大多数安装程序那样设置InstallLocation项。其他安装程序正在做。

由于我没有在wix安装程序中专门设置任何这些键(在Uninstall \ XYZ部分内),因此我假设有一些安装程序属性用于填充现有键。有谁知道由wix安装程序填写InstallLocation的正确方法?我目前正在使用WIX 3.8。