本文整理汇总了C#中Selector.Match方法的典型用法代码示例。如果您正苦于以下问题:C# Selector.Match方法的具体用法?C# Selector.Match怎么用?C# Selector.Match使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Selector
的用法示例。
在下文中一共展示了Selector.Match方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Name_Doesnt_Match_Control_With_TemplatedParent
public void Name_Doesnt_Match_Control_With_TemplatedParent()
{
var control = new Control1 { TemplatedParent = new Mock<ITemplatedControl>().Object };
var target = new Selector().Name("foo");
var activator = target.Match(control);
Assert.False(target.Match(control).ImmediateResult);
}
示例2: OfType_Matches_Control_With_TemplatedParent
public void OfType_Matches_Control_With_TemplatedParent()
{
var control = new Control1 { TemplatedParent = new Mock<ITemplatedControl>().Object };
var target = new Selector().OfType<Control1>();
Assert.True(target.Match(control).ImmediateResult);
}
示例3: OfType_Doesnt_Match_Control_Of_Wrong_Type
public void OfType_Doesnt_Match_Control_Of_Wrong_Type()
{
var control = new Control2();
var target = new Selector().OfType<Control1>();
Assert.False(target.Match(control).ImmediateResult);
}
示例4: OfType_Matches_Control_Of_Correct_Type
public void OfType_Matches_Control_Of_Correct_Type()
{
var control = new Control1();
var target = new Selector().OfType<Control1>();
Assert.True(target.Match(control).ImmediateResult);
}
示例5: Name_Doesnt_Match_Control_Of_Wrong_Name
public void Name_Doesnt_Match_Control_Of_Wrong_Name()
{
var control = new Control1 { Name = "foo" };
var target = new Selector().Name("bar");
Assert.False(target.Match(control).ImmediateResult);
}
示例6: Name_Matches_Control_With_Correct_Name
public void Name_Matches_Control_With_Correct_Name()
{
var control = new Control1 { Name = "foo" };
var target = new Selector().Name("foo");
Assert.True(target.Match(control).ImmediateResult);
}
示例7: PropertyEquals_Matches_When_Property_Has_Matching_Value
public async Task PropertyEquals_Matches_When_Property_Has_Matching_Value()
{
var control = new TextBlock();
var target = new Selector().PropertyEquals(TextBlock.TextProperty, "foo");
var activator = target.Match(control).ObservableResult;
Assert.False(await activator.Take(1));
control.Text = "foo";
Assert.True(await activator.Take(1));
control.Text = null;
Assert.False(await activator.Take(1));
}
示例8: Template_Child_Of_Control_With_Two_Classes
public void Template_Child_Of_Control_With_Two_Classes()
{
var template = new FuncControlTemplate(parent =>
{
return new Border
{
Name = "border",
};
});
var control = new Button
{
Template = template,
};
control.ApplyTemplate();
var selector = new Selector()
.OfType<Button>()
.Class("foo")
.Class("bar")
.Template()
.Name("border");
var border = (Border)((IVisual)control).VisualChildren.Single();
var values = new List<bool>();
var activator = selector.Match(border).ObservableResult;
activator.Subscribe(x => values.Add(x));
Assert.Equal(new[] { false }, values);
control.Classes.AddRange(new[] { "foo", "bar" });
Assert.Equal(new[] { false, true }, values);
control.Classes.Remove("foo");
Assert.Equal(new[] { false, true, false }, values);
}