本文整理汇总了C#中System.Windows.Controls.ContentControl.Measure方法的典型用法代码示例。如果您正苦于以下问题:C# ContentControl.Measure方法的具体用法?C# ContentControl.Measure怎么用?C# ContentControl.Measure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.ContentControl
的用法示例。
在下文中一共展示了ContentControl.Measure方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PageBuilder
public PageBuilder(double width, double height, int marginsLeft, int marginsTop, int marginsRight, int marginsBottom, ContentControl frame)
{
_page = new PageContent();
_fixedPage = new FixedPage {Background = Brushes.White, Width = width, Height = height};
_repeater = new Repeater();
var repeatContainer = new Grid {Margin = new Thickness(marginsLeft, marginsTop, marginsRight, marginsBottom)};
repeatContainer.Children.Add(_repeater);
frame.SetValue(FixedPage.LeftProperty, 0.00);
frame.SetValue(FixedPage.TopProperty, 0.00);
frame.SetValue(FrameworkElement.WidthProperty, _fixedPage.Width);
frame.SetValue(FrameworkElement.HeightProperty, _fixedPage.Height);
_fixedPage.Children.Add(frame);
((IAddChild)_page).AddChild(_fixedPage);
frame.Content = repeatContainer;
frame.Measure(new Size(width, height));
frame.Arrange(new Rect(0, 0, width, height));
_repeater.Width = repeatContainer.ActualWidth;
_repeater.Height = repeatContainer.ActualHeight;
}
示例2: VisualTreeTest
public void VisualTreeTest ()
{
ContentControl c = new ContentControl ();
c.Content = new Rectangle ();
Assert.VisualChildren (c, "#1"); // No visual children
c.Measure (Size.Empty);
Assert.VisualChildren (c, "#2",
new VisualNode<Rectangle> ("#a", (VisualNode [ ]) null)
);
CreateAsyncTest (c, () => {
Assert.VisualChildren (c, "#3",
new VisualNode<ContentPresenter> ("#b",
new VisualNode<Rectangle> ("#c")
)
);
});
}
示例3: IsEnabledTest3
public void IsEnabledTest3 ()
{
ContentControl a = new ContentControl ();
ContentControl b = new ContentControl ();
a.Content = b;
a.IsEnabled = false;
Assert.IsTrue (b.IsEnabled, "#1");
a.ApplyTemplate ();
Assert.IsTrue (b.IsEnabled, "#2");
a.Measure (new Size { Height = 10, Width = 10 });
Assert.IsTrue (b.IsEnabled, "#3");
CreateAsyncTest (a,
() => Assert.IsFalse (b.IsEnabled, "#4")
);
}
示例4: VisualTreeTest5
public void VisualTreeTest5 ()
{
ContentPresenter presenter = null;
ContentControl c = new ContentControl ();
c.Content = "I'm a string";
c.Measure (Size.Empty);
CreateAsyncTest (c,
() => {
Assert.VisualChildren (c, "#1",
new VisualNode<ContentPresenter> ("#a", p => presenter = p, null)
);
Assert.AreEqual (c.Content, presenter.DataContext, "#2");
c.Content = new ConcreteFrameworkElement ();
},
() => {
ContentPresenter old = presenter;
Assert.VisualChildren (c, "#3",
new VisualNode<ContentPresenter> ("#b", p => presenter = p, null)
);
Assert.AreSame (old, presenter, "#4");
Assert.IsNull (presenter.DataContext, "#5");
}
);
}
示例5: RenderVector
/// <summary>
/// Renders the vector icon with the specified resource key, as an image of the specified size, and returns an URI for tile icons.
/// </summary>
/// <remarks>
/// The key is for a ControlTemplate, it's the easiest way to store a path in resources.
/// </remarks>
private static Uri RenderVector( string templateKey, double size )
{
size = Math.Round( size );
string fileName = string.Format( "Shared/ShellContent/{0}_{1}.png", templateKey, size );
var control = new ContentControl();
control.Template = (ControlTemplate) Application.Current.Resources[templateKey];
control.Measure( new Size( size, size ) );
control.Arrange( new Rect( 0, 0, size, size ) );
var bitmap = new WriteableBitmap( (int) size, (int) size );
bitmap.Render( control, null );
bitmap.Invalidate();
using ( var store = IsolatedStorageFile.GetUserStoreForApplication() )
{
if ( store.FileExists( fileName ) )
{
store.DeleteFile( fileName );
}
using ( var stream = store.CreateFile( fileName ) )
{
new PngWriter( stream, bitmap ).Write();
}
}
return new Uri( "isostore:/" + fileName, UriKind.Absolute );
}