本文整理汇总了C#中ContentControl类的典型用法代码示例。如果您正苦于以下问题:C# ContentControl类的具体用法?C# ContentControl怎么用?C# ContentControl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ContentControl类属于命名空间,在下文中一共展示了ContentControl类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: AppendContentControl
/// <summary>
/// Appends the content control.
/// </summary>
/// <param name="contentControl">The content control.</param>
/// <param name="json">The json.</param>
private void AppendContentControl(ContentControl contentControl, StringBuilder json)
{
json.Append(string.Format("{{\"title\":\"{0}\", \"startPage\":{1}, \"endPage\":{2}}}",
JsonEncode(contentControl.Title),
contentControl.StartPageNumber.ToString(_defaultCulture),
contentControl.EndPageNumber.ToString(_defaultCulture)));
}
开发者ID:groupdocs-annotation,项目名称:groupdocs-annotation-net-sample,代码行数:12,代码来源:FileDataJsonSerializer.cs
示例2: GetVisualParents
public void GetVisualParents() {
#endif
Grid grid = new Grid();
ContentControl contentControl = new ContentControl();
TextBox textBox;
Window.Content = grid;
grid.Children.Add(contentControl);
contentControl.ContentTemplate = textBoxTemplate;
#if NETFX_CORE
await
#endif
EnqueueShowWindow();
EnqueueCallback(() => {
textBox = (TextBox)LayoutHelper.FindElement(contentControl, x => x is TextBox);
Assert.AreSame(contentControl, LayoutTreeHelper.GetVisualParents(textBox).Where(x => x is ContentControl).First());
Assert.AreSame(grid, LayoutTreeHelper.GetVisualParents(textBox).Where(x => x is Grid).First());
Assert.AreSame(Window, LayoutTreeHelper.GetVisualParents(textBox).Where(x => x.GetType() == Window.GetType()).First());
Assert.AreSame(contentControl, LayoutTreeHelper.GetVisualParents(textBox, contentControl).Where(x => x is ContentControl).First());
Assert.IsNull(LayoutTreeHelper.GetVisualParents(textBox, contentControl).Where(x => x is Grid).FirstOrDefault());
var presenter = LayoutTreeHelper.GetVisualChildren(contentControl).First();
Assert.IsTrue(new[] { presenter }.SequenceEqual(LayoutTreeHelper.GetVisualParents(textBox, presenter)));
});
EnqueueTestComplete();
}
开发者ID:sk8tz,项目名称:DevExpress.Mvvm.Free,代码行数:26,代码来源:LayoutTreeHelperTests.cs
示例3: ApplyForegroundToFillBinding
public static void ApplyForegroundToFillBinding(ContentControl control)
{
if (control == null)
return;
var element = control.Content as FrameworkElement;
if (element == null)
return;
if (System.TypeExtensions.IsTypeOf(element, typeof(Shape)))
{
var shape = element as Shape;
ResetVerifyAndApplyForegroundToFillBinding(control, shape);
}
else
{
var children = element.GetLogicalChildrenByType<Shape>(false);
foreach (var child in children)
{
var hash = child.GetHashCode();
ResetVerifyAndApplyForegroundToFillBinding(control, child);
}
}
}
开发者ID:selaromdotnet,项目名称:Coding4FunToolkit,代码行数:28,代码来源:ButtonBaseHelper.cs
示例4: CreateTemplateTestCore
void CreateTemplateTestCore(DataTemplate dataTemplate) {
ContentControl content = new ContentControl() { ContentTemplate = dataTemplate };
Window.Content = content;
EnqueueShowWindow();
EnqueueCallback(() => {
Assert.IsNotNull(LayoutTreeHelper.GetVisualChildren(content).OfType<TestView1>().FirstOrDefault());
});
EnqueueTestComplete();
}
开发者ID:LINDAIS,项目名称:DevExpress.Mvvm.Free,代码行数:9,代码来源:ViewLocatorTests.cs
示例5: Setting_Content_Should_Initialize_Control
public void Setting_Content_Should_Initialize_Control()
{
ContentControl target = new ContentControl();
TextBlock child = new TextBlock();
Assert.IsFalse(target.IsInitialized);
target.Content = child;
Assert.IsTrue(target.IsInitialized);
}
开发者ID:modulexcite,项目名称:Avalonia,代码行数:9,代码来源:ContentControlTests.cs
示例6: ApplyTitleOffset
public static void ApplyTitleOffset(ContentControl contentTitle)
{
if (contentTitle == null)
return;
var bottom = -(contentTitle.FontSize / 8.0);
var top = -(contentTitle.FontSize / 2.0) - bottom;
contentTitle.Margin = new Thickness(0, top, 0, bottom);
}
开发者ID:selaromdotnet,项目名称:Coding4FunToolkit,代码行数:10,代码来源:ButtonBaseHelper.cs
示例7: Content_Should_Have_TemplatedParent_Set_To_Null
public void Content_Should_Have_TemplatedParent_Set_To_Null()
{
var target = new ContentControl();
var child = new Border();
target.Template = GetTemplate();
target.Content = child;
target.ApplyTemplate();
Assert.Null(child.TemplatedParent);
}
开发者ID:JackWangCUMT,项目名称:Perspex,代码行数:11,代码来源:ContentControlTests.cs
示例8: CreateNestedTemplate
private Control CreateNestedTemplate(ContentControl control)
{
return new ScrollViewer
{
Template = new FuncControlTemplate<ScrollViewer>(CreateTemplate),
Content = new ContentPresenter
{
Name = "PART_ContentPresenter",
}
};
}
开发者ID:randydotnet,项目名称:Perspex,代码行数:11,代码来源:ScrollViewerTests.cs
示例9: Measure_Should_Call_Child_Measure
public void Measure_Should_Call_Child_Measure()
{
ContentControl target = new ContentControl();
ChildControl child = new ChildControl();
child.RecordInputs = true;
target.Content = child;
target.Measure(new Size(12, 23));
Assert.AreEqual(new Size(12, 23), child.MeasureInput);
}
开发者ID:modulexcite,项目名称:Avalonia,代码行数:11,代码来源:ContentControl_MeasureArrangeTests.cs
示例10: ContentPresenter_Should_Have_TemplatedParent_Set
public void ContentPresenter_Should_Have_TemplatedParent_Set()
{
var target = new ContentControl();
var child = new Border();
target.Template = GetTemplate();
target.Content = child;
target.ApplyTemplate();
var contentPresenter = child.GetVisualParent<ContentPresenter>();
Assert.Equal(target, contentPresenter.TemplatedParent);
}
开发者ID:JackWangCUMT,项目名称:Perspex,代码行数:12,代码来源:ContentControlTests.cs
示例11: Full_Size_Should_Be_Passed_To_Child_ArrangeOverride_For_Stretch_Alignment
public void Full_Size_Should_Be_Passed_To_Child_ArrangeOverride_For_Stretch_Alignment()
{
ContentControl target = new ContentControl();
ChildControl child = new ChildControl();
child.RecordInputs = true;
child.MeasureOutput = new Size(12, 23);
target.Content = child;
target.Arrange(new Rect(new Point(34, 45), new Size(56, 67)));
Assert.AreEqual(new Size(56, 67), child.ArrangeInput);
}
开发者ID:modulexcite,项目名称:Avalonia,代码行数:12,代码来源:ContentControl_MeasureArrangeTests.cs
示例12: OnApplyTemplate
public override void OnApplyTemplate()
#endif
{
base.OnApplyTemplate();
HintContentElement = GetTemplateChild(HintContentElementName) as ContentControl;
UpdateHintVisibility();
UpdateChatBubbleDirection();
UpdateIsEquallySpaced();
}
开发者ID:selaromdotnet,项目名称:Coding4FunToolkit,代码行数:12,代码来源:ChatBubbleTextBox.cs
示例13: Measure_Width_Should_Be_Passed_To_Child_ArrangeOverride_For_Right_Alignment
public void Measure_Width_Should_Be_Passed_To_Child_ArrangeOverride_For_Right_Alignment()
{
ContentControl target = new ContentControl();
ChildControl child = new ChildControl();
child.RecordInputs = true;
child.HorizontalAlignment = HorizontalAlignment.Right;
child.MeasureOutput = new Size(12, 23);
target.Content = child;
target.Arrange(new Rect(new Point(34, 45), new Size(56, 67)));
Assert.AreEqual(new Size(12, 67), child.ArrangeInput);
}
开发者ID:modulexcite,项目名称:Avalonia,代码行数:13,代码来源:ContentControl_MeasureArrangeTests.cs
示例14: Changing_Content_Should_Update_Presenter
public void Changing_Content_Should_Update_Presenter()
{
var target = new ContentControl();
target.Template = GetTemplate();
target.ApplyTemplate();
((ContentPresenter)target.Presenter).UpdateChild();
target.Content = "Foo";
((ContentPresenter)target.Presenter).UpdateChild();
Assert.Equal("Foo", ((TextBlock)target.Presenter.Child).Text);
target.Content = "Bar";
((ContentPresenter)target.Presenter).UpdateChild();
Assert.Equal("Bar", ((TextBlock)target.Presenter.Child).Text);
}
开发者ID:randydotnet,项目名称:Perspex,代码行数:15,代码来源:ContentControlTests.cs
示例15: Template_Should_Be_Instantiated
public void Template_Should_Be_Instantiated()
{
var target = new ContentControl();
target.Content = "Foo";
target.Template = GetTemplate();
target.ApplyTemplate();
((ContentPresenter)target.Presenter).UpdateChild();
var child = ((IVisual)target).VisualChildren.Single();
Assert.IsType<Border>(child);
child = child.VisualChildren.Single();
Assert.IsType<ContentPresenter>(child);
child = child.VisualChildren.Single();
Assert.IsType<TextBlock>(child);
}
开发者ID:CarlSosaDev,项目名称:Avalonia,代码行数:15,代码来源:ContentControlTests.cs
示例16: Clearing_Content_Should_Clear_Logical_Child
public void Clearing_Content_Should_Clear_Logical_Child()
{
var target = new ContentControl();
var child = new Control();
target.Content = child;
Assert.Equal(new[] { child }, target.GetLogicalChildren());
target.Content = null;
Assert.Null(child.Parent);
Assert.Null(child.GetLogicalParent());
Assert.Empty(target.GetLogicalChildren());
}
开发者ID:randydotnet,项目名称:Perspex,代码行数:15,代码来源:ContentControlTests.cs
示例17: Templated_Children_Should_Be_Styled
public void Templated_Children_Should_Be_Styled()
{
var root = new TestRoot();
var target = new ContentControl();
var styler = new Mock<IStyler>();
AvaloniaLocator.CurrentMutable.Bind<IStyler>().ToConstant(styler.Object);
target.Content = "Foo";
target.Template = GetTemplate();
root.Child = target;
target.ApplyTemplate();
styler.Verify(x => x.ApplyStyles(It.IsAny<ContentControl>()), Times.Once());
styler.Verify(x => x.ApplyStyles(It.IsAny<Border>()), Times.Once());
styler.Verify(x => x.ApplyStyles(It.IsAny<ContentPresenter>()), Times.Once());
styler.Verify(x => x.ApplyStyles(It.IsAny<TextBlock>()), Times.Once());
}
开发者ID:CarlSosaDev,项目名称:Avalonia,代码行数:18,代码来源:ContentControlTests.cs
示例18: Template_Should_Be_Instantiated
public void Template_Should_Be_Instantiated()
{
using (var ctx = RegisterServices())
{
var target = new ContentControl();
target.Content = "Foo";
target.Template = GetTemplate();
target.Measure(new Size(100, 100));
var child = ((IVisual)target).VisualChildren.Single();
Assert.IsType<Border>(child);
child = child.VisualChildren.Single();
Assert.IsType<ContentPresenter>(child);
child = child.VisualChildren.Single();
Assert.IsType<TextBlock>(child);
}
}
开发者ID:JackWangCUMT,项目名称:Perspex,代码行数:18,代码来源:ContentControlTests.cs
示例19: Changing_Content_Should_Fire_LogicalChildren_CollectionChanged
public void Changing_Content_Should_Fire_LogicalChildren_CollectionChanged()
{
var target = new ContentControl();
var child1 = new Control();
var child2 = new Control();
var called = false;
target.Template = GetTemplate();
target.Content = child1;
target.ApplyTemplate();
((ContentPresenter)target.Presenter).UpdateChild();
((ILogical)target).LogicalChildren.CollectionChanged += (s, e) => called = true;
target.Content = child2;
target.Presenter.ApplyTemplate();
Assert.True(called);
}
开发者ID:randydotnet,项目名称:Perspex,代码行数:19,代码来源:ContentControlTests.cs
示例20: GetVisualChildren
public void GetVisualChildren() {
#endif
Grid grid = new Grid();
ContentControl contentControl = new ContentControl();
TextBox textBox;
Window.Content = grid;
grid.Children.Add(contentControl);
contentControl.ContentTemplate = textBoxTemplate;
#if NETFX_CORE
await
#endif
EnqueueShowWindow();
EnqueueCallback(() => {
textBox = (TextBox)LayoutHelper.FindElement(contentControl, x => x is TextBox);
Assert.AreSame(contentControl, LayoutTreeHelper.GetVisualChildren(grid).Where(x => x is ContentControl).FirstOrDefault());
Assert.AreSame(textBox, LayoutTreeHelper.GetVisualChildren(grid).Where(x => x is TextBox).FirstOrDefault());
});
EnqueueTestComplete();
}
开发者ID:sk8tz,项目名称:DevExpress.Mvvm.Free,代码行数:20,代码来源:LayoutTreeHelperTests.cs
注:本文中的ContentControl类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论