WPF Paso a Paso

Anuncio
WPF Paso a Paso
TALLERES DE DISEÑO DE FORMULARIOS
EJEMPLO DE DISEÑO EN UN FORMULARIO WPF
<Window x:Class="Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="535">
<Grid ShowGridLines="True">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Label Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="0"
VerticalAlignment="Center" HorizontalAlignment="Center">Title</Label>
<Label Grid.Column="0" Grid.Row ="1" VerticalAlignment="Center">
Firstname:</Label>
<TextBox Grid.Column="1" Grid.Row="1" Width="100"
Height="30"></TextBox>
<Label Grid.Column="0" Grid.Row ="2" VerticalAlignment="Center">
Lastname:</Label>
<TextBox Grid.Column="1" Grid.Row="2" Width="100"
Height="30"></TextBox>
</Grid>
</Window>
DISEÑO DE FORMAS EN FORMULARIO WPF
<Window x:Class="WPF"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WPF Samples" Height="260" Width="230" Name="Window1">
<Canvas>
<Ellipse Canvas.Left="50" Canvas.Top="50" Width="100" Height="100"
Stroke="Blue" StrokeThickness="4" Fill="Yellow" />
<Ellipse Canvas.Left="60" Canvas.Top="65" Width="25" Height="25"
Stroke="Blue" StrokeThickness="3" Fill="White" />
<Ellipse Canvas.Left="70" Canvas.Top="75" Width="5" Height="5"
Fill="Black" />
<Path Name="boca" Stroke="Blue" StrokeThickness="4"
Data="M 62,125 Q 95,122 102,108" />
<Line X1="124" X2="132" Y1="144" Y2="166" Stroke="Blue"
StrokeThickness="4" />
<Line X1="114" X2="133" Y1="169" Y2="166" Stroke="Blue"
StrokeThickness="4" />
<Line X1="92" X2="82" Y1="146" Y2="168" Stroke="Blue"
StrokeThickness="4" />
<Line X1="68" X2="83" Y1="160" Y2="168" Stroke="Blue"
StrokeThickness="4" />
<ComboBox Canvas.Left="90" Canvas.Top="0" Height="23"
Name="ComboBox1" Width="120" />
</Canvas>
</Window>
CODIGO FUENTE EN FORMULARIO EVENTOS
SELECCIÓN DE ITEM DE COMBO
CARGA DE DATOS EN COMBO.
Private Sub ComboBox1_SelectionChanged(ByVal sender As System.Object, ByVal e
As System.Windows.Controls.SelectionChangedEventArgs) Handles
ComboBox1.SelectionChanged
Dim itemSelec As ComboBoxItem = CType(Me.ComboBox1.SelectedValue,
ComboBoxItem)
If itemSelec.Content.Equals("Feliz") Then
boca.Data = Geometry.Parse("M 62,125 Q 95,122 102,108")
Else
boca.Data = Geometry.Parse("M 62,125 Q 95,122 102,128")
End If
End Sub
Private Sub Window1_Loaded(ByVal sender As System.Object, ByVal e As
System.Windows.RoutedEventArgs) Handles MyBase.Loaded
Dim cbi As New ComboBoxItem
cbi.Content = "Feliz"
Me.ComboBox1.Items.Add(cbi)
Dim cbi2 As New ComboBoxItem
cbi2.Content = "Triste"
Me.ComboBox1.Items.Add(cbi2)
End Sub
Descargar