问题列表 - 第31842页

将VerticalAlignment属性设置为所有控件

我的WPF UserControl包含两个堆栈面板,每个面板包含标签,文本框和单选按钮.
我想使用尽可能少的代码将VerticalAlignment属性设置为Center我的UserControl中的所有控件.

现在我有以下解决方案:

  • 蛮力 - 投入VerticalAlignment="Center"每个控制
  • 定义一种样式FrameworkElement并直接应用它
  • 为用户控件上的每种控件类型定义样式(这需要3个样式定义,但会自动将样式应用于控件)

这三个解决方案需要太多代码.
有没有其他方法可以写这个?
我希望定义样式FrameworkElement会自动将属性设置为所有控件,但它不起作用.

这是我当前XAML的片段(我省略了第二个,非常相似的堆栈面板):

<UserControl.Resources>
    <Style x:Key="BaseStyle" TargetType="FrameworkElement">
        <Setter Property="VerticalAlignment" Value="Center" />
    </Style>
</UserControl.Resources>
<Grid>
    <StackPanel Orientation="Horizontal">
        <TextBlock Style="{StaticResource BaseStyle}" Text="Value:" />
        <RadioButton Style="{StaticResource BaseStyle}">Standard</RadioButton>
        <RadioButton Style="{StaticResource BaseStyle}">Other</RadioButton>
        <TextBox Style="{StaticResource BaseStyle}" Width="40"/>
    </StackPanel>
</Grid>
Run Code Online (Sandbox Code Playgroud)

编辑:
Re Will的评论:我真的很讨厌在代码隐藏中编写控件格式代码的想法.XAML应该足以实现这种非常简单的用户控制.

Re Muad'Dib的评论:我在用户控件中使用的控件来源于FrameworkElement,所以这不是问题.

wpf layout styles

6
推荐指数
1
解决办法
2873
查看次数

13
推荐指数
1
解决办法
3886
查看次数

保护登录页面

我正在尝试为我的drupal网站添加额外的安全性.我删除了登录块,但也可以通过http://mydrupalsite.com/user访问

它仍然需要允许管理员帐户,但有没有办法用htaccess或比drupal开箱即用的更强大的东西来保护这个单页?

php .htaccess drupal content-management-system drupal-6

0
推荐指数
1
解决办法
748
查看次数

预加载@ Font-Face字体以停止Firefox闪烁/延迟

我一直在阅读有关此事的帖子,但仍无法找到答案.有没有人想出如何预加载字体以停止闪烁/延迟?

干杯.埃里克

fonts embedded-fonts

12
推荐指数
2
解决办法
2万
查看次数

CKEditor在jQuery UI重新排序时冻结

我试图使用jQuery UI框架重新排序动态创建的CKEditors列表,但我遇到了编辑器释放的问题.当我刚刚使用a时<textarea>,它工作得很好,但现在,在拖动操作完成后,它不会让用户写任何文本.

这是Javascript代码:

$(function() {
    $("#list").sortable({
        placeholder: 'ui-state-highlight'
    });
    $("#list").disableSelection();

    for (i=0;i<10;i++)
    {
        addEditor();
    }
});

function addEditor()
{
    alert("Hello");
    var editor_fields = document.editors.elements["editor[]"];

    var editorAmount = 0;

    if (editor_fields.length)
    {
        editorAmount = editor_fields.length;
    }
    else
    {
        editorAmount = 1;
    }

    var newElem = $('#editor_container' + editorAmount).clone().attr('id', 'editor_container' + (editorAmount + 1));

    newElem.html("<textarea class='editor' name='editor[]' id='editor" + (editorAmount + 1) + "' rows='4' cols='30'></textarea>");

    $("#editor_container" + editorAmount).after(newElem);

    $("#editor" + (editorAmount + 1)).ckeditor();
}
Run Code Online (Sandbox Code Playgroud)

这是HTML代码:

<form name="editors">
    <ul id="list"> …
Run Code Online (Sandbox Code Playgroud)

jquery fckeditor dynamic-forms ckeditor

6
推荐指数
1
解决办法
3488
查看次数

来自当前用户的MyDocuments,Wix中的buildin变量?

我需要安装一些文件C:\Documents and Settings\currentUser\SomeFolder.我找不到一些buildin函数/变量.

有人可以帮我/告诉我<DirectoryRef Id="TARGETDIR">我的问题的结构或解决方案吗?

谢谢.

deployment wix wixlib

3
推荐指数
1
解决办法
2319
查看次数

如何将选择器和事件捕获从jQuery转换为纯JS?

有人可以帮助将此代码转换为纯JS:

$(document).ready(function() {
    $("textarea").bind("keydown", function(event) {
        var textarea = $(this).get(0);          
        //further will need only textarea and event vars
    }
});
Run Code Online (Sandbox Code Playgroud)

我不关心跨浏览器兼容性,只要它适用于当前的FF和Chrome.

javascript jquery

2
推荐指数
1
解决办法
171
查看次数

如何更改泛型类型值?

在我的应用程序中,我创建了TList类型列表,用于存储整数或双精度:

TKList<T> = class
  private
    FItems: TList<T>;
    function GetItem(Index: Integer): T;
    procedure SetItem(Index: Integer; const Value: T);
    function GetMaxValue(): T;
    function GetMinValue(): T;
  public
    constructor Create; overload;
    constructor Create(const AKList: TKList<T>); overload;
    destructor Destroy; override;
    procedure Assign(const AKList: TKList<T>);
    function Add(const AValue: T): Integer;
    procedure Clear;
    function Count: Integer;
    procedure Invert;
    function ToString: string; override;
    function Info: string;
    property Values[Index: Integer]: T read GetItem write SetItem; default;
  end;
Run Code Online (Sandbox Code Playgroud)

如何实现Invert()过程来反转泛型List中的值?

提前致谢.

delphi generics delphi-2010

0
推荐指数
1
解决办法
596
查看次数

有关反转字符串的问题

我正在尝试做一个简单的字符串操作.输入是"谋杀",我想得到"谋杀".

我试过这个

String str = "murder";
StringBuffer buf = new StringBuffer(str);
// buf is now "murder", so i append the reverse which is "redrum"
buf.append(buf.reverse());
System.out.println(buf);
Run Code Online (Sandbox Code Playgroud)

但现在我得到"redrumredrum"而不是"murderredrum".

谁能解释我的程序有什么问题?谢谢.

java string reverse

3
推荐指数
1
解决办法
674
查看次数

登录后将用户转发回上一页

我可以在登录Drupal时将用户发送回上一页吗?

他可以从我网站的不同页面登录.不仅有一个登录节点.我想把他送回他所在的页面.

谢谢

drupal drupal-6

3
推荐指数
1
解决办法
3801
查看次数