我正在尝试绑定 ListBoxItem 的工具提示。我在 ControlTemplate 中定义了这个:
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<ControlTemplate.Resources>
<conv:IconConverter x:Key="IconConverter" />
<conv:FirstImageConverter x:Key="FirstImageConverter"/>
<conv:DebugConverter x:Key="dbg"/>
</ControlTemplate.Resources>
<Border ...>
<StackPanel>
<Image MaxHeight="160" Stretch="UniformToFill" Source="{Binding Icon,Converter={StaticResource IconConverter},ConverterParameter=128}" Height="128"/>
<TextBlock x:Name="lblName" Text="{Binding Name}" />
</StackPanel>
<Border.ToolTip>
<DockPanel LastChildFill="True" Margin="2" MaxWidth="800"
DataContext="{Binding Images,Converter={StaticResource FirstImageConverter}}"
IsEnabled="{Binding Images,Converter={StaticResource FirstImageConverter},ConverterParameter=enabled}">
<TextBlock DockPanel.Dock="Bottom" Width="Auto" MaxWidth="600" Text="{Binding Caption}" Height="Auto" />
<Image x:Name="imgFullSize" DockPanel.Dock="Top" Stretch="None" Width="Auto" Source="{Binding Filename,Converter={StaticResource IconConverter}}"/>
</DockPanel>
</Border.ToolTip>
Run Code Online (Sandbox Code Playgroud)
是的,我收到一个绑定错误: System.Windows.Data Error: 3 : Cannot find element that provides DataContext. BindingExpression:Path=Images; DataItem=null; target element is 'DockPanel' (Name=''); …
我有一个使用内置ASP.NET成员资格提供程序的应用程序.有两个角色(管理员和员工).我希望管理员能够查看当前员工列表,添加或删除员工以及重置密码.到目前为止,我发现的信息很少,但Membership.Provider.GetAllUsers看起来很有希望.有什么办法可以在GridView中显示列表吗?
至少,我需要能够通过网站添加和删除用户.
如果我有两个类,一个继承自另一个类,并且我在两者中都使用相同的方法/属性名称,那么无论当前对象是否已被强制转换为它的基类,如何使该方法调用子类.
例如(省略了无关的部分):
public class MyBase {
public int GetNumber() {
return 1;
}
}
public class MyDerived : MyBase {
public new int GetNumber() {
return 20;
}
}
MyDervied someVar = new MyDerived();
int derivedVar = someVar.GetNumber(); // 20
MyBase baseVar = (MyBase)someVar;
int baseVar = baseVar.GetNumber(); // 1
Run Code Online (Sandbox Code Playgroud)
我的直觉是对派生类使用override而不是new,但是我得到一个"没有成员被发现覆盖".
我有一个IGroup类型的对象列表.这些可以嵌套到umlimited级别,我试图在从数据库中检索它们之后对它们进行分组.我无法理解如何递归地将所有组添加到正确的父母.任何以null作为父级的组都是顶级组.我不能保证他们从数据库中出来的顺序.
public interface IGroup {
string ID { get; set; }
string Name { get; set; }
string ParentID { get; set; }
IList<IGroup> Groups { get; set; }
...
Run Code Online (Sandbox Code Playgroud)
所以,如果我有一个列表:
Group1: ID = g1, ParentID = null
Group1a: ID = g2, ParentID = g1
Group2: ID = g3, ParentID = null
Group1b: ID = g4, ParentID = g3
Group1bc: ID = g5, ParentID = g4
Run Code Online (Sandbox Code Playgroud)
我正在尝试将它们分组为:
|Group1
|--Group1a
|--Group1b
|--|
|--Group1bc
|Group2
Run Code Online (Sandbox Code Playgroud)
有人想要递归分组吗?
在下面的代码中,MousePressImage是类的依赖属性ButtonControl.以下绑定不起作用.感谢您帮助解决此问题.
Value="{Binding RelativeSource={x:Static RelativeSource.Self},
Path=MousePressImage}"/>
<Style TargetType="{x:Type local:ButtonControl}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:ButtonControl}">
<Border>
<Image x:Name="img"
Source="pack://application:,,,/Recipe_06_13;component/Resources/normal.bmp"
/>
</Border>
<!--<Border x:Name="border">
<Border.Background>
<ImageBrush x:Name="img"
ImageSource="/Recipe_06_13;component/Resources/fatal.png"/>
</Border.Background>
</Border>-->
<ControlTemplate.Triggers>
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="img"
Property="Source"
Value="{Binding RelativeSource={x:Static RelativeSource.Self},
Path=MousePressImage}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Run Code Online (Sandbox Code Playgroud)
我创造了ButtonControl这样的.
<local:ButtonControl Height="48" Width="160"
MouseOverImage="pack://application:,,,/Recipe_06_13;component/Resources/Over.bmp"
MousePressImage="pack://application:,,,/Recipe_06_13;component/Resources/Press.bmp"
DisableImage=" ">
</local:ButtonControl>
Run Code Online (Sandbox Code Playgroud) 我正在尝试将一个ViewController连接到TabController中的选项卡.我将选项卡类型设置为NavigationController,将我的ViewController子类设置为选项卡的标识.我还为选项卡设置了NIB名称.当我使用NavigationContollers的任何其他选项卡时,一切正常,但是一个特定视图抛出异常,此类不是键值txtPassword的键值编码兼容.
2011-07-14 17:11:10.784 myApp[5027:207] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x5a36500> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key txtPassword.'
*** Call stack at first throw:
(
0 CoreFoundation 0x013305a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x01484313 objc_exception_throw + 44
2 CoreFoundation 0x013304e1 -[NSException raise] + 17
3 Foundation 0x00195677 _NSSetUsingKeyValueSetter + 135
4 Foundation 0x001955e5 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 285
5 UIKit 0x0061930c -[UIRuntimeOutletConnection connect] + 112
6 CoreFoundation 0x012a68cf -[NSArray makeObjectsPerformSelector:] + …Run Code Online (Sandbox Code Playgroud) 我有一个正则表达式匹配列表中的一系列字符,但我想阻止它匹配一个单词.
我的正则表达式是:
^widget/([\w\d~]+)/?(?:[\w\d~]+)/?$
Run Code Online (Sandbox Code Playgroud)
我希望它像这样匹配:
widget/JQYHHU - 视图小部件,应该匹配widget/JQYHHU/ - 视图小部件,应该匹配widget/JQYHHU/bag-of-screws - 视图小部件,应该匹配widget/JQYHHU/bag-of-screws/ - 视图小部件,应该匹配widget/add-查看部件,应该不匹配widget/add/-查看部件,应该不匹配是否可以添加条件以匹配字符,但是如果它们拼写单词"add"则不能?
我正在使用Cocos2d来拖动精灵,并尝试在选择精灵时添加边框.我可以让我的白色背景显示,但我的边界证明特别困难.我有这个代码:
if(self.selectedSprite)
self.selectedSprite = nil;
CCLayerColor *selectedLayer = [[CCLayerColor alloc] init];
// CCSprite *backgroundSprite = [CCSprite spriteWithFile:@"white_1x1.gif" rect:CGRectMake(2,2,self.boundingBox.size.width-4,self.boundingBox.size.height-4)];
CCSprite *backgroundSprite = [CCSprite spriteWithFile:@"white_1x1.gif" rect:CGRectMake(0,0,self.boundingBox.size.width,self.boundingBox.size.height)];
[backgroundSprite setContentSize:CGSizeMake(self.contentSize.width-4, self.contentSize.height-4)];
backgroundSprite.anchorPoint = ccp(0,0);
CCRenderTexture* rt = [CCRenderTexture renderTextureWithWidth:backgroundSprite.texture.contentSize.width + 2 height:backgroundSprite.texture.contentSize.height+2];
[backgroundSprite setFlipY:YES];
[backgroundSprite setColor:ccc3(0,0,0)];
ccBlendFunc originalBlendFunc = [backgroundSprite blendFunc];
[backgroundSprite setBlendFunc:(ccBlendFunc) { GL_SRC_ALPHA, GL_ONE }];
CGPoint bottomLeft = ccp(backgroundSprite.texture.contentSize.width * backgroundSprite.anchorPoint.x + 1, backgroundSprite.texture.contentSize.height * backgroundSprite.anchorPoint.y + 1);
CGPoint position = ccpSub([backgroundSprite position], ccp(-backgroundSprite.contentSize.width / 2.0f, -backgroundSprite.contentSize.height / 2.0f));
[rt begin];
for …Run Code Online (Sandbox Code Playgroud) 我尝试用Jquery更改css属性.我做
wrapperInner.css('overflow', 'visible');
Run Code Online (Sandbox Code Playgroud)
但价值仍然保持不变.我发出警报alert(wrapperInner.css('overflow'))并显示出来hidden.这是css
.tribe-events-calendar td div.wrapper div.wrapper_inner {
position:relative;
overflow:hidden!important;
}
Run Code Online (Sandbox Code Playgroud) echo"<td> <a href ='del.php?id=$id' onclick='return confirm('Are you sure?');'><center>Delete</center></a></td>";
Run Code Online (Sandbox Code Playgroud)
我想要一个提示信息,因为用户将点击"删除",如果他/她将按"确定"然后它将重定向到一个页面,数据将被删除,如果他/她将按"取消",那么什么都不会发生.通过使用上面的代码我无法得到我的提示框和数据直接被删除.
c# ×2
ios ×2
iphone ×2
wpf ×2
.net ×1
asp.net ×1
binding ×1
cclayer ×1
css ×1
data-binding ×1
datacontext ×1
inheritance ×1
javascript ×1
jquery ×1
membership ×1
objective-c ×1
php ×1
recursion ×1
regex ×1
tooltip ×1
xcode ×1