当前位置: 首页>>代码示例>>C#>>正文


C# Target.ApplyTemplate方法代码示例

本文整理汇总了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);
        }
开发者ID:MarkWalls,项目名称:Perspex,代码行数:25,代码来源:SelectingItemsControlTests.cs

示例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);
        }
开发者ID:MarkWalls,项目名称:Perspex,代码行数:19,代码来源:SelectingItemsControlTests.cs

示例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);
        }
开发者ID:MarkWalls,项目名称:Perspex,代码行数:28,代码来源:SelectingItemsControlTests.cs

示例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();
        }
开发者ID:MarkWalls,项目名称:Perspex,代码行数:10,代码来源:SelectingItemsControlTests.cs

示例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);
        }
开发者ID:MarkWalls,项目名称:Perspex,代码行数:25,代码来源:SelectingItemsControlTests.cs

示例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);
        }
开发者ID:MarkWalls,项目名称:Perspex,代码行数:20,代码来源:SelectingItemsControlTests.cs

示例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);
        }
开发者ID:MarkWalls,项目名称:Perspex,代码行数:20,代码来源:SelectingItemsControlTests.cs

示例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);
        }
开发者ID:MarkWalls,项目名称:Perspex,代码行数:12,代码来源:SelectingItemsControlTests.cs

示例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);
        }
开发者ID:MarkWalls,项目名称:Perspex,代码行数:19,代码来源:SelectingItemsControlTests.cs

示例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]);
        }
开发者ID:MarkWalls,项目名称:Perspex,代码行数:31,代码来源:SelectingItemsControlTests.cs


注:本文中的Target.ApplyTemplate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。