Size Структура
Определение
public value class Size : IFormattable
[System.ComponentModel.TypeConverter(typeof(System.Windows.SizeConverter))]
public struct Size : IFormattable
[System.ComponentModel.TypeConverter(typeof(System.Windows.SizeConverter))]
[System.Serializable]
public struct Size : IFormattable
[<System.ComponentModel.TypeConverter(typeof(System.Windows.SizeConverter))>]
type Size = struct
interface IFormattable
[<System.ComponentModel.TypeConverter(typeof(System.Windows.SizeConverter))>]
[<System.Serializable>]
type Size = struct
interface IFormattable
Public Structure Size
Implements IFormattable
- Наследование
- Атрибуты
- Реализации
Примеры
В следующем примере показано, как использовать Size структуру в коде.The following example demonstrates how to use a Size structure in code.
virtual Size MeasureOverride(Size availableSize) override
{
Size^ panelDesiredSize = gcnew Size();
// In our example, we just have one child.
// Report that our panel requires just the size of its only child.
for each (UIElement^ child in InternalChildren)
{
child->Measure(availableSize);
panelDesiredSize = child->DesiredSize;
}
return *panelDesiredSize ;
}
protected override Size MeasureOverride(Size availableSize)
{
Size panelDesiredSize = new Size();
// In our example, we just have one child.
// Report that our panel requires just the size of its only child.
foreach (UIElement child in InternalChildren)
{
child.Measure(availableSize);
panelDesiredSize = child.DesiredSize;
}
return panelDesiredSize ;
}
Protected Overrides Function MeasureOverride(ByVal availableSize As System.Windows.Size) As System.Windows.Size
Dim panelDesiredSize As Size = New Size()
' In our example, we just have one child.
' Report that our panel requires just the size of its only child.
For Each child As UIElement In InternalChildren
child.Measure(availableSize)
panelDesiredSize = child.DesiredSize
Next
Return panelDesiredSize
End Function
Комментарии
Size особенно полезен, так как он описывает Height и Width объект.Size is particularly useful because it describes both the Height and Width of an object. Size широко используется системой макета для упорядочения и измерения элементов.Size is used extensively by the layout system to arrange and measure elements.
Использование атрибута XAMLXAML Attribute Usage
<object property="width,height"/>
Значения XAMLXAML Values
widthwidth
Значение, большее или равное 0, указывающее значение Width Size структуры.A value greater than or equal to 0 that specifies the Width of the Size structure.
равноheight
Значение, большее или равное 0, указывающее значение Height Size структуры.A value greater than or equal to 0 that specifies the Height of the Size structure.
Конструкторы
Size(Double, Double) |
Инициализирует новый экземпляр структуры Size и присваивает ему начальные значения |
Свойства
Empty |
Получает значение, которое представляет статический пустой объект Size.Gets a value that represents a static empty Size. |
Height |
Получает или задает свойство Height данного экземпляра Size.Gets or sets the Height of this instance of Size. |
IsEmpty |
Получает значение, которое показывает, является ли данный экземпляр объекта Size свойством Empty.Gets a value that indicates whether this instance of Size is Empty. |
Width |
Получает или задает свойство Width данного экземпляра Size.Gets or sets the Width of this instance of Size. |
Методы
Equals(Object) |
Сравнивает на равенство объект с экземпляром объекта Size.Compares an object to an instance of Size for equality. |
Equals(Size) |
Сравнивает значение с экземпляром объекта Size на наличие равенства.Compares a value to an instance of Size for equality. |
Equals(Size, Size) |
Сравнивает на равенство два экземпляра Size.Compares two instances of Size for equality. |
GetHashCode() |
Получает хэш-код для этого экземпляра Size.Gets the hash code for this instance of Size. |
Parse(String) |
Возвращает экземпляр Size из преобразованного объекта String.Returns an instance of Size from a converted String. |
ToString() |
Возвращает строку String, которая представляет этот объект Size.Returns a String that represents this Size object. |
ToString(IFormatProvider) |
Возвращает строку String, которая представляет этот экземпляр объекта Size.Returns a String that represents this instance of Size. |
Операторы
Equality(Size, Size) |
Сравнивает на равенство два экземпляра Size.Compares two instances of Size for equality. |
Explicit(Size to Point) |
Явно преобразует экземпляр Size в экземпляр Point.Explicitly converts an instance of Size to an instance of Point. |
Explicit(Size to Vector) |
Явно преобразует экземпляр Size в экземпляр Vector.Explicitly converts an instance of Size to an instance of Vector. |
Inequality(Size, Size) |
Сравнивает два экземпляра Size на предмет их неравенства.Compares two instances of Size for inequality. |
Явные реализации интерфейса
IFormattable.ToString(String, IFormatProvider) |
Данный тип или член поддерживает инфраструктуру Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) и не предназначен для непосредственного использования из кода.This type or member supports the Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code. |