<!-- XAML file --> <Window xmlns="http://schemas.microsoft.com/2003/xaml" xmlns:def="Definition" def:Class="Application1.Window1" def:CodeBehind="Window1.xaml.cs" Text="Application1" Visible="True" > <DockPanel xmlns="http://schemas.microsoft.com/2003/xaml" xmlns:def="Definition" def:Language="C#" Background="White"> <FlowPanel ID="sourceFlowPanel" MouseLeftButtonDown="OnLeftMouseDown" Margin="10,10,0,0" Background="cyan" Width="150px" Height="150px"> <Text ID="caption" Margin="10,10,20,20" FontSize="16">Click on Me</Text> </FlowPanel> </DockPanel> </Window> // C# Codebehind class using System; using MSAvalon.Windows; using MSAvalon.Windows.Input; using MSAvalon.Windows.Controls; using MSAvalon.Windows.Documents; using MSAvalon.Windows.Navigation; using MSAvalon.Windows.Shapes; using MSAvalon.Windows.Data; namespace Application1 { public partial class Window1 : Window { private bool expanded = false; private void OnLeftMouseDown(object sender, MouseButtonEventArgs e) { if (expanded) { sourceFlowPanel.Width = new Length(sourceFlowPanel.Width.Value/2); sourceFlowPanel.Height = new Length(sourceFlowPanel.Height.Value/2); caption.TextRange.Text = "Pulsa"; expanded = false; } else { sourceFlowPanel.Width = new Length(2 * sourceFlowPanel.Width.Value); sourceFlowPanel.Height = new Length(2 * sourceFlowPanel.Height.Value); caption.TextRange.Text = "Gracias por pulsar"; expanded = true; } } } } Fuente 1. Ejemplo de mezcla del código declarativo y el funcional. |