本文整理汇总了C#中ContentControl类的典型用法代码示例。如果您正苦于以下问题:C# ContentControl类的具体用法?C# ContentControl怎么用?C# ContentControl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ContentControl类属于命名空间,在下文中一共展示了ContentControl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例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);
}
}
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
示例8: CreateNestedTemplate
private Control CreateNestedTemplate(ContentControl control)
{
return new ScrollViewer
{
Template = new FuncControlTemplate<ScrollViewer>(CreateTemplate),
Content = new ContentPresenter
{
Name = "PART_ContentPresenter",
}
};
}
示例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);
}
示例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);
}
示例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);
}
示例12: OnApplyTemplate
public override void OnApplyTemplate()
#endif
{
base.OnApplyTemplate();
HintContentElement = GetTemplateChild(HintContentElementName) as ContentControl;
UpdateHintVisibility();
UpdateChatBubbleDirection();
UpdateIsEquallySpaced();
}
示例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);
}
示例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);
}
示例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);
}