小编coo*_*rgo的帖子

ruby watir-webdriver使用哈希中的变量

我正在尝试创建在其中间具有可变性的哈希.我似乎无法将变量视为变量仅作为文字.变量是数组颜色中的元素,
例如

text1 = {:style => 'background-color: variable;'}
Run Code Online (Sandbox Code Playgroud)

我认为这会奏效.

text1 = {:style => 'background-color: #{variable};'}
Run Code Online (Sandbox Code Playgroud)

以下工作,但它是一个圆形的方法

text2 = ''
text2  << "background-color: " << variable << ";"
text1 = {:style => text2}
Run Code Online (Sandbox Code Playgroud)

ruby watir-webdriver

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

XAML使用单选按钮启用和禁用带数据绑定的文本框

我试图弄清楚如何启用和禁用带有单选按钮和数据绑定的文本框.看起来我应该能够将文本框IsEnabled绑定到布尔值并修改该值,但我无法让它工作.我想要几组单选按钮和文本框,所以我想要一个通用的方法来处理问题.我试图使用转换器,但因为我没有使用任何x:名称我不确定这些在这种情况下会有所帮助.我可以让他们启用/禁用单选按钮,但这不是我想要做的.我的代码主要显示了我为第一个文本框尝试的解决方案.

Xaml代码

    <Grid>
    <StackPanel>
        <RadioButton GroupName="grp1" Content="Enable TextBox"  IsEnabled="{Binding Bttn1, Mode=TwoWay}" IsChecked="{Binding Bttn1}" Checked="RadioButton_Checked" Unchecked="RadioButton_UnChecked" />
        <RadioButton GroupName="grp1" Content="Disable TextBox" IsEnabled="{Binding Bttn2}" />
        <TextBox IsEnabled="{Binding Txtbx1, Mode=TwoWay}" BindingGroup="{Binding grp1}" ></TextBox>

        <RadioButton GroupName="grp2" Content="Enable TextBox"  IsEnabled="{Binding Bttn3, Mode=TwoWay}" IsChecked="{Binding Bttn3}" Checked="RadioButton_Checked" Unchecked="RadioButton_UnChecked" />
        <RadioButton GroupName="grp2" Content="Disable TextBox" IsEnabled="{Binding Bttn4}" />
        <TextBox IsEnabled="{Binding Txtbx2, Mode=TwoWay}" BindingGroup="{Binding grp2}" ></TextBox>
    </StackPanel>
</Grid>
Run Code Online (Sandbox Code Playgroud)

ViewModel代码

    private bool _bttn1;
    private bool _bttn2;
    private bool _bttn3;
    private bool _bttn4;
    private bool _txtbx1;
    private bool _txtbx2;

    public bool Bttn1 …
Run Code Online (Sandbox Code Playgroud)

c# xaml mvvm

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

标签 统计

c# ×1

mvvm ×1

ruby ×1

watir-webdriver ×1

xaml ×1