Order of precedence for sizing-related properties that are implemented by Window. : Window « Windows Presentation Foundation « VB.Net Tutorial






<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="SizingPrecedenceSampleCSharp.MainWindow"
    Title="Sizing Sample" Height="300" Width="300" SizeToContent="WidthAndHeight">
  <StackPanel>
      <CheckBox Name="setWSCB" Content="Set WindowState?"/>
      <ComboBox Name="wsLB" IsEnabled="{Binding ElementName=setWSCB,Path=IsChecked}">
        <ComboBoxItem IsSelected="True">Minimized</ComboBoxItem>
        <ComboBoxItem>Maximized</ComboBoxItem>
        <ComboBoxItem>Normal</ComboBoxItem>
      </ComboBox>
      <CheckBox Name="setMinWidthCB" Content="Set MinWidth?"/>
      <TextBox Name="minWidthTB" IsEnabled="{Binding ElementName=setMinWidthCB,Path=IsChecked}">500</TextBox>
      <CheckBox Name="setMinHeightCB" Content="Set MinHeight?"/>
      <TextBox Name="minHeightTB" IsEnabled="{Binding ElementName=setMinHeightCB,Path=IsChecked}">500</TextBox>
      <CheckBox Name="setSTCCB" Content="Set SizeToContent?"/>
      <ComboBox Name="stcLB" IsEnabled="{Binding ElementName=setSTCCB,Path=IsChecked}">
        <ComboBoxItem IsSelected="True">Manual</ComboBoxItem>
        <ComboBoxItem>Width</ComboBoxItem>
        <ComboBoxItem>Height</ComboBoxItem>
        <ComboBoxItem>WidthAndHeight</ComboBoxItem>
      </ComboBox>
      <CheckBox Name="setMaxWidthCB" Content="Set MaxWidth?"></CheckBox>
      <TextBox Name="maxWidthTB" IsEnabled="{Binding ElementName=setMaxWidthCB,Path=IsChecked}">800</TextBox>
      <CheckBox Name="setMaxHeightCB" Content="Set MaxHeight?"></CheckBox>
      <TextBox Name="maxHeightTB" IsEnabled="{Binding ElementName=setMaxHeightCB,Path=IsChecked}">800</TextBox>
      <CheckBox Name="setWidthCB" Content="Set Width?"></CheckBox>
      <TextBox Name="widthTB" IsEnabled="{Binding ElementName=setWidthCB,Path=IsChecked}">700</TextBox>
      <CheckBox Name="setHeightCB" Content="Set Height?"></CheckBox>
      <TextBox Name="heightTB" IsEnabled="{Binding ElementName=setHeightCB,Path=IsChecked}">700</TextBox>
      <Button Click="showWindowButton_Click">Show Window</Button>
  </StackPanel>
</Window>

//File:Window.xaml.vb

Imports System
Imports System.Windows

Namespace SizingPrecedenceSampleCSharp
  Public Partial Class MainWindow
    Inherits System.Windows.Window

    Public Sub New()
      InitializeComponent()
    End Sub

    Private Sub showWindowButton_Click(sender As Object, e As RoutedEventArgs)
      Dim sw As New MainWindow()

      If Me.setWSCB.IsChecked = True Then
        sw.WindowState = CType([Enum].Parse(GetType(WindowState), Me.wsLB.Text), WindowState)
      End If
      If Me.setMinWidthCB.IsChecked = True Then
        sw.MinWidth = Double.Parse(Me.minWidthTB.Text)
      End If
      If Me.setMinHeightCB.IsChecked = True Then
        sw.MinHeight = Double.Parse(Me.minHeightTB.Text)
      End If
      If Me.setMaxWidthCB.IsChecked = True Then
        sw.MaxWidth = Double.Parse(Me.maxWidthTB.Text)
      End If
      If Me.setMaxHeightCB.IsChecked = True Then
        sw.MaxHeight = Double.Parse(Me.maxHeightTB.Text)
      End If
      If Me.setWidthCB.IsChecked = True Then
        sw.Width = Double.Parse(Me.widthTB.Text)
      End If
      If Me.setHeightCB.IsChecked = True Then
        sw.Height = Double.Parse(Me.heightTB.Text)
      End If
      If Me.setSTCCB.IsChecked = True Then
        sw.SizeToContent = CType([Enum].Parse(GetType(SizeToContent), Me.stcLB.Text), SizeToContent)
      End If

      sw.Show()
    End Sub
  End Class
End Namespace
WPF Order Of Precedence For Sizingrelated Properties That Are Implemented By Window








16.57.Window
16.57.1.Custom WindowCustom Window
16.57.2.Set window size in XAMLSet window size in XAML
16.57.3.A simple user-login XAML pageA simple user-login XAML page
16.57.4.User login screen with no layout or formattingUser login screen with no layout or formatting
16.57.5.Automatically Size the Main Application Window to Accommodate Its ContentAutomatically Size the Main Application Window to Accommodate Its Content
16.57.6.Window OwnershipWindow Ownership
16.57.7.Creating the main panel and add to Window in CodeCreating the main panel and add to Window in Code
16.57.8.Show window based on button nameShow window based on button name
16.57.9.Set a Default ButtonSet a Default Button
16.57.10.Window with Menu, ToolBar, StatusBarWindow with Menu, ToolBar, StatusBar
16.57.11.Order of precedence for sizing-related properties that are implemented by Window.Order of precedence for sizing-related properties that are implemented by Window.
16.57.12.Use Window Activated and Deactivated event to control a media fileUse Window Activated and Deactivated event to control a media file
16.57.13.Animated Video WindowAnimated Video Window
16.57.14.Use WindowState to make full screen window, change resize mode to NoReSizeUse WindowState to make full screen window, change resize mode to NoReSize
16.57.15.Do not handle events until Window is fully initialized.Do not handle events until Window is fully initialized.
16.57.16.Load resource from Window ResourcesLoad resource from Window Resources
16.57.17.Launch a window with defined XAMLLaunch a window with defined XAML
16.57.18.Display window as dialogDisplay window as dialog
16.57.19.Save Window Position to RegistrySave Window Position to Registry
16.57.20.Center a Window to ScreenCenter a Window to Screen