FontWeight.Compare(FontWeight, FontWeight) Metod

Definition

Jämför två instanser av FontWeight.

public:
 static int Compare(System::Windows::FontWeight left, System::Windows::FontWeight right);
public static int Compare(System.Windows.FontWeight left, System.Windows.FontWeight right);
static member Compare : System.Windows.FontWeight * System.Windows.FontWeight -> int
Public Shared Function Compare (left As FontWeight, right As FontWeight) As Integer

Parametrar

left
FontWeight

Det första FontWeight objektet som ska jämföras.

right
FontWeight

Det andra FontWeight objektet att jämföra.

Returer

Ett Int32 värde som anger relationen mellan de två instanserna av FontWeight. När returvärdet är mindre än noll är left det mindre än right. När det här värdet är noll anger det att båda operanderna är lika med. När värdet är större än noll anger det att left är större än right.

Exempel

I följande kodexempel Compare används metoden för att utvärdera två FontWeight objekt.

// Return the typefaces for the selected font family name and font values.
Typeface typeface1 = new Typeface(new FontFamily("Arial"), FontStyles.Normal, FontWeights.Normal, FontStretches.Normal);
Typeface typeface2 = new Typeface(new FontFamily("Arial"), FontStyles.Normal, FontWeights.UltraBold, FontStretches.Normal);

if (FontWeight.Compare(typeface1.Weight, typeface2.Weight) < 0)
{
    // Code execution follows this path because
    // the FontWeight of typeface1 (Normal) is less than of typeface2 (UltraBold).
}
' Return the typefaces for the selected font family name and font values.
Dim typeface1 As New Typeface(New FontFamily("Arial"), FontStyles.Normal, FontWeights.Normal, FontStretches.Normal)
Dim typeface2 As New Typeface(New FontFamily("Arial"), FontStyles.Normal, FontWeights.UltraBold, FontStretches.Normal)

If FontWeight.Compare(typeface1.Weight, typeface2.Weight) < 0 Then
    ' Code execution follows this path because
    ' the FontWeight of typeface1 (Normal) is less than of typeface2 (UltraBold).
End If

Kommentarer

Lättare teckenvikter är mindre än tyngre teckenvikter. Till exempel är teckensnittsvikten "Ljus" eller "Normal" mindre än teckensnittsvikten "UltraBold".

Gäller för