有没有办法在WPF中打印内存集合或可变大小?
我正在使用以下代码打印ListView控件.但是当内容大于垂直滚动条接管并切割内容时.
PrintDialog printDialog = new PrintDialog();
printDialog.ShowDialog();
printDialog.PrintVisual(lvDocumentSummary, "testing printing!");
Run Code Online (Sandbox Code Playgroud) 我正在尝试将样式应用于父div中包含的内部div.父div还包含大量的其他div,但我只想将颜色应用于[0] div.
$("#parentDiv div")[0].css('background-color', 'red');
Run Code Online (Sandbox Code Playgroud)
出于某种原因,它说"没有定义css功能!"
如果FirstName值为null或为空,我正在抛出一个ApplicationException,我试图在TextBlock中显示错误消息,该消息是ErrorTemplate的一部分.但它始终显示"异常已被抛出调用目标".
public string FirstName
{
get { return _firstName;}
set
{
if(String.IsNullOrEmpty(value))
throw new ApplicationException("FirstName cannot be null or empty!");
_firstName = value;
OnPropertyChanged("FirstName");
}
}
<Style x:Key="TextBoxStyle" TargetType="TextBox">
<Setter Property="Validation.ErrorTemplate">
<Setter.Value>
<ControlTemplate>
<DockPanel LastChildFill="True">
<TextBlock DockPanel.Dock="Right"
Foreground="Orange"
FontSize="12pt"
Text="{Binding ElementName=MyAdorner, Path=AdornedElement.(Validation.Errors)[0].ErrorContent}">
</TextBlock>
<Border BorderBrush="Green" BorderThickness="1">
<AdornedElementPlaceholder Name="MyAdorner" />
</Border>
</DockPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Run Code Online (Sandbox Code Playgroud)
最后这里是TextBox控件:
<TextBox Name="txtFirstName" Style="{StaticResource TextBoxStyle}" Grid.Column="1" Grid.Row="0" Height="20" Width="100" Margin="10">
<TextBox.Text>
<Binding Path="FirstName">
<Binding.ValidationRules>
<ExceptionValidationRule />
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
Run Code Online (Sandbox Code Playgroud) 我不确定为什么没有在Binding上调用该属性.这是代码:
<myusercontrol
Text ="{Binding Description, UpdateSourceTrigger=LostFocus,Mode=TwoWay, ValidatesOnDataErrors=True}"
IsReadOnly ="{Binding AllowEditing}"
/>
Run Code Online (Sandbox Code Playgroud)
这是myusercontrol IsReadOnly属性:
public static DependencyProperty IsReadOnlyProperty = DependencyProperty.Register("IsReadOnly", typeof (bool),
typeof (
myusercontrol));
public bool IsReadOnly
{
get
{
return ((bool) GetValue(IsReadOnlyProperty));
}
set
{
MessageBox.Show(value.ToString());
SetValue(IsReadOnlyProperty, !value);
OnPropertyChanged("IsReadOnly");
}
}
Run Code Online (Sandbox Code Playgroud)
永远不会显示消息框!有任何想法吗!
我在Xcode命令行工具项目中添加了一个简单的类.课程如下:
#import <Foundation/Foundation.h>
@interface Foo : NSObject {
}
@end
Run Code Online (Sandbox Code Playgroud)
和
#import "Foo.h"
@implementation Foo
@end
Run Code Online (Sandbox Code Playgroud)
当我引用了foo.h用#import "Foo.h"在我的主文件,我得到的所有类型的错误.我将Foundation.frameowork添加为我的框架.
/Developer/SDKs/MacOSX10.6.sdk/System/
Library/Frameworks/Foundation.framework/Headers/
NSObjCRuntime.h:189:1: error: expected identifier or '(' [3]
/Developer/SDKs/MacOSX10.6.sdk/System/
Library/Frameworks/Foundation.framework/Headers/
NSObjCRuntime.h:197:50: error: unknown type name 'Protocol' [3]
我刚刚在 Github 上推送了一些代码,现在我在代码中看到以下内容:
// HelloWorld Layer
@interface GameScene : CCLayer
{
CCSprite *devil;
CCParticleFire *fireball;
CollisionManager *collisionManager;
Demon *demon;
Spaceship *spaceship;
Scoreboard *scoreboard;
Environment *env;
int lives;
<<<<<<< HEAD
=======
CGSize windowSize;
>>>>>>> 37190b1e49c75517ce26e1040aaaed12bd2a013c
Run Code Online (Sandbox Code Playgroud)
这里发生了什么?
我需要在MKMapView上显示数千个引脚,我需要一个好的委托方法,我可以添加引脚.didUserUpdateLocation很糟糕,因为它被多次触发.向MKMapView添加数千个引脚的最佳方法是什么?
更新:
我只是使用BOOL检查一次加载引脚,它似乎工作得非常好!
-(void) mapView:(MKMapView *) mv didUpdateUserLocation:(MKUserLocation *)userLocation
{
NSLog(@"didUpdateUserLocation");
if(self.isMapped) return;
for(Facility *facility in self.facilities)
{
CLLocationCoordinate2D facilityCoord = { facility.latitude,facility.longitude };
MapPoint *mp = [[MapPoint alloc] initWithCoordinate:facilityCoord title:facility.facilityName];
[mv addAnnotation:mp];
}
self.isMapped = YES;
}
Run Code Online (Sandbox Code Playgroud) 我使用以下代码将js对象转换为json但似乎没有工作:
var params = new Object();
params.fileCode = $(this).val();
var something = jQuery.stringify(params);
Run Code Online (Sandbox Code Playgroud)
更新1:
我将代码更新为此但仍未成功:
var params = new Object();
params.fileCode = $(this).val();
var p = $.toJSON(params); // object does not support this property or method
var s = JSON.stringify(params); // JSON is not defined
Run Code Online (Sandbox Code Playgroud) 我有一个TR行id(myRow),它有一个子表,该表有行类".CONTENTROW".我使用以下代码删除除"第一个"之外的所有类".CONTENTROW".这是我正在使用的代码:
var myRow = $("#" + rowId).next().clone();
$(myRow).find(".CONTENTROW tr:gt(0)").remove();
Run Code Online (Sandbox Code Playgroud)
上面似乎没有工作,也没有删除任何行.我尝试使用JSFiddle,但JSFiddle以一种奇怪的方式表现而不是令人耳目一新.
JSFIDDLE:http://jsfiddle.net/Xt6VQ/1/
我试图在WPF中使用验证.我创建了一个NotNullOrEmptyValidationRule,如下所示:
public class NotNullOrEmptyValidationRule : ValidationRule
{
public override ValidationResult Validate(object value, CultureInfo cultureInfo)
{
if (String.IsNullOrEmpty(value as String))
return new ValidationResult(false, "Value cannot be null or empty");
return new ValidationResult(true, null);
}
}
Run Code Online (Sandbox Code Playgroud)
现在,我需要在我的应用程序中使用它.在我的App.xaml文件中,我为TextBox声明了Style.这是宣言.
<Style x:Key="textBoxStyle" TargetType="{x:Type TextBox}">
<Setter Property="Background" Value="Green"/>
<Style.Triggers>
<Trigger Property="Validation.HasError" Value="True">
<Setter Property="Background" Value="Red"/>
<Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self},Path=(Validation.Errors)[0].ErrorContent}"/>
</Trigger>
</Style.Triggers>
</Style>
Run Code Online (Sandbox Code Playgroud)
现在,我想在我的TextBox上使用它,所以我使用以下代码:
<TextBox Style="{StaticResource textBoxStyle}">
<TextBox.Text>
<Binding>
<Binding.ValidationRules>
<NotNullOrEmptyValidationRule />
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
Run Code Online (Sandbox Code Playgroud)
Tag NotNullOrEmptyValidationRule上出现错误.XAML语法检查程序无法解析NotNullOrEmptyValidationRule.我甚至尝试过放置命名空间但它似乎不起作用.
wpf ×4
jquery ×3
validation ×2
data-binding ×1
git ×1
github ×1
ios ×1
json ×1
mkmapview ×1
objective-c ×1
printdialog ×1
printing ×1
xcode4 ×1