我正在研究一个大型的WPF项目,在调试期间,我的输出窗口充满了这些烦人的警告:
System.Windows.Data信息:10:无法使用绑定检索值,并且不存在有效>回退值; 使用默认值. BindingExpression:路径= HorizontalContentAlignment; 的DataItem = NULL; target元素是' ComboBoxItem '(Name =''); target属性是'HorizontalContentAlignment'(类型>'HorizontalAlignment')
在具体示例中,ComboBoxItem以这种方式设置样式:
<Style x:Key="{x:Type ComboBoxItem}" TargetType="{x:Type ComboBoxItem}">
<Setter Property="OverridesDefaultStyle" Value="True"/>
<Setter Property="SnapsToDevicePixels" Value="True"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ComboBoxItem}">
<Border
Name="bd"
Padding="4,4,4,4"
SnapsToDevicePixels="True"
CornerRadius="2,2,2,2">
<ContentPresenter />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsHighlighted" Value="true">
<Setter TargetName="bd" Property="Background" Value="{StaticResource MediumBrush}"/>
<Setter TargetName="bd" Property="Padding" Value="4,4,4,4"/>
<Setter TargetName="bd" Property="CornerRadius" Value="2,2,2,2"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Run Code Online (Sandbox Code Playgroud)
我知道问题是由ComboBoxItem的默认主题定义生成的,其中包含以下内容:
<Setter Property="Control.HorizontalContentAlignment">
<Setter.Value>
<Binding Path="HorizontalContentAlignment" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=ItemsControl, AncestorLevel=1}" />
</Setter.Value>
</Setter>
Run Code Online (Sandbox Code Playgroud)
但我也认为使用
<Setter Property="OverridesDefaultStyle" …
Run Code Online (Sandbox Code Playgroud) 嗨我想在我的XAML,WPF applcation中使用的一个单独的类中获取applcation路径.在Animals.cs中,
string aPath2 = Application.StartupPath;
MessageBox.Show(path);
Run Code Online (Sandbox Code Playgroud)
它会调整错误 错误CS0117:'System.Windows.Application'不包含'StartupPath'的定义
我必须将数据提供给treeview,我将从applcation路径中的文件中获取所有详细信息.
如果您尝试读取'get'变量的值,如果未在URL中设置所述变量会发生什么.示例:您请求页面test.php
,在该文件中它尝试读取值$_GET['message']
.在这种情况下会发生什么?剂量值刚刚返回为''
?
这是否意味着,如果我总是期望输入一个值,并且我不愿意接受''我可以做类似的事情的价值
$foo = $_GET['bar'];
if($foo == ''){
// Handle my 'error'
}
else
{
// $foo should now have a value that I can work with
}
Run Code Online (Sandbox Code Playgroud)
请记住,我知道我可以使用isset($_GET['bar'])
但是我不只是想知道它是否已经设置,我不在乎是否它,我只关心它是否有一个不仅仅是一个空的值串.
我需要建议TextBox,用户可以在其中编写一些关键字(使用指定的关键字搜索文件存档).但是可以使用某些分隔符按顺序输入关键字.
例如: keyword1; keyword2; key...
我想用GWT制作它.
请告诉我你是否了解一些实现示例(可能是在JavaScript/jQuery中)或如何做到这一点.
TIA
我在WPF 4应用程序中呈现一个奇怪的渲染问题,因为它渲染了一些文本,因为它正在拉伸它并使其非常窄.
.net 3.5:
.net 4.0:
起初我认为它可能是字体的问题,但我也看到Blend 4 beta中的同样问题:
我正在运行XP SP3,Visual Studio 2010 Professional,所有内容都是最新的.我没有注意到我在同一台机器上构建的Silverlight 4应用程序的任何此类问题......其他人看到过这个或者知道它为什么会发生?
在C#中使用Xml序列化时,我想将输入XML的一部分反序列化为XmlNode.
所以,鉴于这个XML:
<Thing Name="George">
<Document>
<subnode1/>
<subnode2/>
</Document>
</Thing>
Run Code Online (Sandbox Code Playgroud)
我想将Document元素反序列化为XmlNode.
下面是我给出上面的XML的尝试,将Document设置为'subnode1'元素而不是'Document'元素.
如何获取将Document属性设置为Document元素的代码?
using System;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
[Serializable]
public class Thing
{
[XmlAttribute] public string Name {get;set;}
public XmlNode Document { get; set; }
}
class Program
{
static void Main()
{
const string xml = @"
<Thing Name=""George"">
<Document>
<subnode1/>
<subnode2/>
</Document>
</Thing>";
var s = new XmlSerializer(typeof(Thing));
var thing = s.Deserialize(new StringReader(xml)) as Thing;
}
}
Run Code Online (Sandbox Code Playgroud)
但是,当我使用XmlSerializer将上面的XML反序列化为Thing实例时,Document属性包含子元素'subnode1',而不是'Document'元素.
如何让XmlSerializer将Document设置为包含'Document'元素的XmlNode?
(注意:我可以通过指定XmlElement []类型的属性并将其标记为[XmlAnyElement]来获取Document元素,但是将其设置为所有无法识别的元素的数组,而不是仅仅一个名为"Document"的元素.
我有这个功能:
if (is_dir($dir)) {
//are we able to open it?
if ($dh = opendir($dir)) {
//Let's cycle
while (($subdir = readdir($dh)) !== false) {
if ($subdir != "." && $subdir != "..") {
echo $subdir;
}
}
}
Run Code Online (Sandbox Code Playgroud)
返回:
directory1 , directory2, directory3 etc.. etc..
Run Code Online (Sandbox Code Playgroud)
无论如何,如果我这样做:
if (is_dir($dir)) {
//are we able to open it?
if ($dh = opendir($dir)) {
//Let's cycle
while (($subdir = readdir($dh)) !== false) {
if ($subdir != "." && $subdir != "..") {
if (is_dir($subdir)) …
Run Code Online (Sandbox Code Playgroud) 我正在将几个站点转换为.net 4.0,我似乎遇到了日期区域化的问题.
这段代码:
Date.Today.AddDays((Date.Today.DayOfWeek - 1) * -1).ToString()
Run Code Online (Sandbox Code Playgroud)
在.net 3.5中产生:'19/04/2010 00:00:00'但是一旦我将应用程序池更改为4.0,它就会产生:'4/19/2010 12:00:00 AM'
我在哪里可以更改管理此设置的设置?
在某些应用程序上,我看到当一个链接被触摸时,使用safari进行打开链接并退出当前应用程序.我希望使用此功能从其他应用程序运行消息应用程序.我可以这样做吗?如果是,怎么办?