Change MaxHeight : Rectangle « Windows Presentation Foundation « VB.Net Tutorial

Home
VB.Net Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statements
5.Date Time
6.Class Module
7.Development
8.Collections
9.Generics
10.Attributes
11.Event
12.LINQ
13.Stream File
14.GUI
15.GUI Applications
16.Windows Presentation Foundation
17.2D Graphics
18.I18N Internationlization
19.Reflection
20.Regular Expressions
21.Security
22.Socket Network
23.Thread
24.Windows
25.XML
26.Database ADO.net
27.Design Patterns
VB.Net
VB.Net by API
VB.Net Tutorial » Windows Presentation Foundation » Rectangle 
16.67.27.Change MaxHeight
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="Height_MinHeight_MaxHeight.Window1"
    Title="Height Properties Sample">
  <StackPanel Margin="10">
      <Canvas Height="200" MinWidth="200" Name="myCanvas">
           <Rectangle HorizontalAlignment="Center" Canvas.Top="50" Canvas.Left="50"  Name="rect1" Fill="#4682b4" Height="100" Width="100"/>
      </Canvas>
      <Button Name="Button1" Click="clipRect">Canvas.ClipToBounds="True"</Button>
      <Button Name="Button2" Margin="0,5,5,5" Click="unclipRect">Canvas.ClipToBounds="False"</Button>
     
    <TextBlock Grid.Row="1" Grid.Column="4" Margin="10,0,0,0" TextWrapping="Wrap">Set the Rectangle MaxHeight:</TextBlock>
    <ListBox Grid.Column="5" Grid.Row="1" Margin="10,0,0,0" Height="50" Width="50" SelectionChanged="changeMaxHeight">
      <ListBoxItem>25</ListBoxItem>
      <ListBoxItem>50</ListBoxItem>
      <ListBoxItem>75</ListBoxItem>
      <ListBoxItem>100</ListBoxItem>
      <ListBoxItem>125</ListBoxItem>
      <ListBoxItem>150</ListBoxItem>
      <ListBoxItem>175</ListBoxItem>
      <ListBoxItem>200</ListBoxItem> 
    </ListBox>
  

  </StackPanel>
</Window>

//File:Window.xaml.vb

Imports System
Imports System.Windows
Imports System.Windows.Media
Imports System.Windows.Controls
Imports System.Windows.Documents

Namespace Height_MinHeight_MaxHeight
  Public Partial Class Window1
    Inherits Window
    Public Sub changeMaxHeight(sender As Object, args As SelectionChangedEventArgs)
      Dim li As ListBoxItem = TryCast(TryCast(sender, ListBox).SelectedItem, ListBoxItem)
      Dim sz1 As [Double[Double].Parse(li.Content.ToString())
      rect1.MaxHeight = sz1
      rect1.UpdateLayout()
      Console.WriteLine("ActualHeight is set to " + rect1.ActualHeight)
      Console.WriteLine("Height is set to " + rect1.Height)
      Console.WriteLine("MinHeight is set to " + rect1.MinHeight)
      Console.WriteLine("MaxHeight is set to " + rect1.MaxHeight)
    End Sub


    Public Sub clipRect(sender As Object, args As RoutedEventArgs)
      myCanvas.ClipToBounds = True
      Console.WriteLine("Canvas.ClipToBounds is set to " + myCanvas.ClipToBounds)
    End Sub
    Public Sub unclipRect(sender As Object, args As RoutedEventArgs)
      myCanvas.ClipToBounds = False
      Console.WriteLine("Canvas.ClipToBounds is set to " + myCanvas.ClipToBounds)
    End Sub
  End Class
End Namespace
WPF Change Max Height
16.67.Rectangle
16.67.1.Use Rectangle, TextBlock and Button as the VisualBrushUse Rectangle, TextBlock and Button as the VisualBrush
16.67.2.Set Stroke, StrokeThickness for RectangleSet Stroke, StrokeThickness for Rectangle
16.67.3.Fill Rectangles with static ImageBrush resourcesFill Rectangles with static ImageBrush resources
16.67.4.Fill Rectangle with BisqueFill Rectangle with Bisque
16.67.5.Rotating rectanglesRotating rectangles
16.67.6.Rounded rectangleRounded rectangle
16.67.7.Rectangle with explicit size and positionRectangle with explicit size and position
16.67.8.Rectangles with size and position controlled by parentRectangles with size and position controlled by parent
16.67.9.Using ImageBrush to fill a RectangleUsing ImageBrush to fill a Rectangle
16.67.10.Draws a 100 by 50 rectangle with a solid blue fillDraws a 100 by 50 rectangle with a solid blue fill
16.67.11.Draws a 100 by 50 rectangle with a solid blue fill, a black outline, and rounded cornersDraws a 100 by 50 rectangle with a solid blue fill, a black outline, and rounded corners
16.67.12.Rectangle StrokeThicknessRectangle StrokeThickness
16.67.13.Rectangle.StrokeRectangle.Stroke
16.67.14.Use Customized LinearGradientBrush to paint a RectangleUse Customized LinearGradientBrush to paint a Rectangle
16.67.15.Set RadiusX and RadiuxY for RectangleSet RadiusX and RadiuxY for Rectangle
16.67.16.Fill Rectangle with LinearGradientBrush static resourceFill Rectangle with LinearGradientBrush static resource
16.67.17.Using a DrawingBrush resource to draw RectangleUsing a DrawingBrush resource to draw Rectangle
16.67.18.A rectangle with a linear fillA rectangle with a linear fill
16.67.19.A large rectangle built using an image brushA large rectangle built using an image brush
16.67.20.Fill Rectangle with ResourceFill Rectangle with Resource
16.67.21.Add Rectangle.Triggers collection into a styleAdd Rectangle.Triggers collection into a style
16.67.22.DashArray StrokeDashArray Stroke
16.67.23.Dash patternsDash patterns
16.67.24.Put Rectangle into TextBlockPut Rectangle into TextBlock
16.67.25.Rectangle mouse down eventRectangle mouse down event
16.67.26.Rectangle mouse down previewRectangle mouse down preview
16.67.27.Change MaxHeightChange MaxHeight
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.