本文整理汇总了C#中Target.ApplyTemplate方法的典型用法代码示例。如果您正苦于以下问题:C# Target.ApplyTemplate方法的具体用法?C# Target.ApplyTemplate怎么用?C# Target.ApplyTemplate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Target
的用法示例。
在下文中一共展示了Target.ApplyTemplate方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Clearing_Items_Should_Clear_Selection
public void Clearing_Items_Should_Clear_Selection()
{
var items = new PerspexList<Item>
{
new Item(),
new Item(),
};
var target = new Target
{
Items = items,
Template = this.Template(),
};
target.ApplyTemplate();
target.SelectedIndex = 1;
Assert.Equal(items[1], target.SelectedItem);
Assert.Equal(1, target.SelectedIndex);
target.Items = null;
Assert.Equal(null, target.SelectedItem);
Assert.Equal(-1, target.SelectedIndex);
}
示例2: Item_IsSelected_Should_Initially_Be_False
public void Item_IsSelected_Should_Initially_Be_False()
{
var items = new[]
{
new Item(),
new Item(),
};
var target = new Target
{
Items = items,
Template = this.Template(),
};
target.ApplyTemplate();
Assert.False(items[0].IsSelected);
Assert.False(items[1].IsSelected);
}
示例3: Raising_IsSelectedChanged_On_Item_Should_Update_Selection
public void Raising_IsSelectedChanged_On_Item_Should_Update_Selection()
{
var items = new[]
{
new Item(),
new Item(),
};
var target = new Target
{
Items = items,
Template = this.Template(),
};
target.ApplyTemplate();
target.SelectedItem = items[1];
Assert.False(items[0].IsSelected);
Assert.True(items[1].IsSelected);
items[0].IsSelected = true;
items[0].RaiseEvent(new RoutedEventArgs(SelectingItemsControl.IsSelectedChangedEvent));
Assert.Equal(target.SelectedIndex, 0);
Assert.Equal(target.SelectedItem, items[0]);
Assert.True(items[0].IsSelected);
Assert.False(items[1].IsSelected);
}
示例4: Setting_SelectedItem_With_No_Items_Should_Not_Throw_Exception
public void Setting_SelectedItem_With_No_Items_Should_Not_Throw_Exception()
{
var target = new Target
{
Template = this.Template(),
};
target.ApplyTemplate();
target.SelectedItem = new Item();
}
示例5: Setting_SelectedItem_To_Not_Present_Item_Should_Clear_Selection
public void Setting_SelectedItem_To_Not_Present_Item_Should_Clear_Selection()
{
var items = new[]
{
new Item(),
new Item(),
};
var target = new Target
{
Items = items,
Template = this.Template(),
};
target.ApplyTemplate();
target.SelectedItem = items[1];
Assert.Equal(items[1], target.SelectedItem);
Assert.Equal(1, target.SelectedIndex);
target.SelectedItem = new Item();
Assert.Equal(null, target.SelectedItem);
Assert.Equal(-1, target.SelectedIndex);
}
示例6: Setting_SelectedItem_Should_Set_SelectedIndex
public void Setting_SelectedItem_Should_Set_SelectedIndex()
{
var items = new[]
{
new Item(),
new Item(),
};
var target = new Target
{
Items = items,
Template = this.Template(),
};
target.ApplyTemplate();
target.SelectedItem = items[1];
Assert.Equal(items[1], target.SelectedItem);
Assert.Equal(1, target.SelectedIndex);
}
示例7: Setting_SelectedItem_Should_Set_Item_IsSelected_True
public void Setting_SelectedItem_Should_Set_Item_IsSelected_True()
{
var items = new[]
{
new Item(),
new Item(),
};
var target = new Target
{
Items = items,
Template = this.Template(),
};
target.ApplyTemplate();
target.SelectedItem = items[1];
Assert.False(items[0].IsSelected);
Assert.True(items[1].IsSelected);
}
示例8: Setting_SelectedIndex_With_No_Items_Should_Not_Throw_Exception
public void Setting_SelectedIndex_With_No_Items_Should_Not_Throw_Exception()
{
var target = new Target
{
Template = this.Template(),
};
target.ApplyTemplate();
target.SelectedIndex = 2;
Assert.Equal(-1, target.SelectedIndex);
}
示例9: Setting_SelectedIndex_Should_Coerce
public void Setting_SelectedIndex_Should_Coerce()
{
var items = new[]
{
new Item(),
new Item(),
};
var target = new Target
{
Items = items,
Template = this.Template(),
};
target.ApplyTemplate();
target.SelectedIndex = 2;
Assert.Equal(1, target.SelectedIndex);
}
示例10: Raising_IsSelectedChanged_On_Someone_Elses_Item_Should_Not_Update_Selection
public void Raising_IsSelectedChanged_On_Someone_Elses_Item_Should_Not_Update_Selection()
{
var items = new[]
{
new Item(),
new Item(),
};
var target = new Target
{
Items = items,
Template = this.Template(),
};
target.ApplyTemplate();
target.SelectedItem = items[1];
var notChild = new Item
{
IsSelected = true,
};
target.RaiseEvent(new RoutedEventArgs
{
RoutedEvent = SelectingItemsControl.IsSelectedChangedEvent,
Source = notChild,
OriginalSource = notChild,
});
Assert.Equal(target.SelectedItem, items[1]);
}