{"id":22,"date":"2024-04-25T04:13:48","date_gmt":"2024-04-25T04:13:48","guid":{"rendered":"https:\/\/jlmota.net\/?p=22"},"modified":"2024-04-25T04:21:42","modified_gmt":"2024-04-25T04:21:42","slug":"formulario-de-inicio-con-wpf","status":"publish","type":"post","link":"https:\/\/jlmota.net\/index.php\/2024\/04\/25\/formulario-de-inicio-con-wpf\/","title":{"rendered":"Formulario de Inicio con WPF"},"content":{"rendered":"\n<p><strong>Windows Presentation Foundation<\/strong>&nbsp;(<strong>WPF<\/strong>) es una&nbsp;tecnolog\u00eda&nbsp;de&nbsp;Microsoft, presentada como parte de&nbsp;Windows Vista. Permite el desarrollo de interfaces de interacci\u00f3n en Windows tomando caracter\u00edsticas de&nbsp;aplicaciones&nbsp;Windows y de&nbsp;aplicaciones web.<\/p>\n\n\n\n<p>WPF ofrece una amplia infraestructura y potencia gr\u00e1fica con la que es posible desarrollar aplicaciones visualmente atractivas, con facilidades de interacci\u00f3n que incluyen&nbsp;animaci\u00f3n,&nbsp;v\u00eddeo,&nbsp;audio,&nbsp;documentos, navegaci\u00f3n o gr\u00e1ficos&nbsp;3D. Separa, con el lenguaje declarativo&nbsp;XAML&nbsp;y los&nbsp;lenguajes de programaci\u00f3n&nbsp;de&nbsp;.NET, la&nbsp;interfaz&nbsp;de interacci\u00f3n de la l\u00f3gica del negocio, propiciando una arquitectura&nbsp;Modelo Vista Controlador&nbsp;para el desarrollo de las aplicaciones.<\/p>\n\n\n\n<!--more-->\n\n\n\n<ol class=\"wp-block-list\">\n<li>Crear un proyecto nuevo con WPF y C#. Y estructurar las carpetas del proyecto de la siguiente manera.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"538\" src=\"https:\/\/jlmota.net\/wp-content\/uploads\/2024\/04\/image-1024x538.png\" alt=\"\" class=\"wp-image-23\" srcset=\"https:\/\/jlmota.net\/wp-content\/uploads\/2024\/04\/image-1024x538.png 1024w, https:\/\/jlmota.net\/wp-content\/uploads\/2024\/04\/image-300x158.png 300w, https:\/\/jlmota.net\/wp-content\/uploads\/2024\/04\/image-768x404.png 768w, https:\/\/jlmota.net\/wp-content\/uploads\/2024\/04\/image-1536x808.png 1536w, https:\/\/jlmota.net\/wp-content\/uploads\/2024\/04\/image-1140x600.png 1140w, https:\/\/jlmota.net\/wp-content\/uploads\/2024\/04\/image.png 1919w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>2. En la carpeta View, crear una nueva pagina WPF llamada <strong>LoginView.xaml<\/strong> <\/p>\n\n\n\n<p>3. Agregar el siguiente c\u00f3digo :<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\n&lt;Window x:Class=&quot;WPF_LoginForm.View.LoginView&quot;\n        xmlns=&quot;http:\/\/schemas.microsoft.com\/winfx\/2006\/xaml\/presentation&quot;\n        xmlns:x=&quot;http:\/\/schemas.microsoft.com\/winfx\/2006\/xaml&quot;\n        xmlns:d=&quot;http:\/\/schemas.microsoft.com\/expression\/blend\/2008&quot;\n        xmlns:mc=&quot;http:\/\/schemas.openxmlformats.org\/markup-compatibility\/2006&quot;\n        xmlns:local=&quot;clr-namespace:WPF_LoginForm.View&quot;\n        mc:Ignorable=&quot;d&quot;\n        Title=&quot;LoginView&quot; Height=&quot;550&quot; Width=&quot;800&quot;\n        WindowStyle=&quot;None&quot;\n        ResizeMode=&quot;NoResize&quot;\n        WindowStartupLocation=&quot;CenterScreen&quot;\n        Background=&quot;Transparent&quot;\n        AllowsTransparency=&quot;True&quot;\n        MouseDown=&quot;Window_MouseDown&quot;&gt;\n\n    &lt;Border CornerRadius=&quot;12&quot;&gt;\n        &lt;Border.Background&gt;\n            &lt;ImageBrush ImageSource=&quot;\/Images\/ITL.jpeg&quot;\n                        Stretch=&quot;Fill&quot;\/&gt;\n        &lt;\/Border.Background&gt;\n\n        &lt;Border CornerRadius=&quot;10&quot;                    \n            BorderThickness=&quot;2&quot;\n            Opacity=&quot;0.95&quot;&gt;\n\n            &lt;Border.BorderBrush&gt;\n                &lt;LinearGradientBrush StartPoint=&quot;0,0&quot; EndPoint=&quot;1,1&quot;&gt;\n                    &lt;GradientStop Color=&quot;#462AD8&quot; Offset=&quot;0&quot;\/&gt;\n                    &lt;GradientStop Color=&quot;#DA34AE&quot; Offset=&quot;0.75&quot;\/&gt;\n                    &lt;GradientStop Color=&quot;#8A16C1&quot; Offset=&quot;1&quot;\/&gt;\n                &lt;\/LinearGradientBrush&gt;\n            &lt;\/Border.BorderBrush&gt;\n\n            &lt;Border.Background&gt;\n                &lt;LinearGradientBrush StartPoint=&quot;0,1&quot; EndPoint=&quot;1,0&quot;&gt;\n                    &lt;GradientStop Color=&quot;#060531&quot; Offset=&quot;0&quot;\/&gt;\n                    &lt;GradientStop Color=&quot;#1B1448&quot; Offset=&quot;1&quot;\/&gt;\n                &lt;\/LinearGradientBrush&gt;\n            &lt;\/Border.Background&gt;\n\n            &lt;Grid&gt;\n                &lt;Grid.RowDefinitions&gt;\n                    &lt;RowDefinition Height=&quot;30&quot;\/&gt;\n                    &lt;RowDefinition\/&gt;\n                &lt;\/Grid.RowDefinitions&gt;\n\n                &lt;Grid Grid.Row=&quot;0&quot;&gt;\n\n                    &lt;Grid.ColumnDefinitions&gt;\n                        &lt;ColumnDefinition\/&gt;\n                        &lt;ColumnDefinition Width=&quot;25&quot;\/&gt;\n                        &lt;ColumnDefinition Width=&quot;25&quot;\/&gt;\n                        &lt;ColumnDefinition Width=&quot;5&quot;\/&gt;\n                    &lt;\/Grid.ColumnDefinitions&gt;\n\n                    &lt;TextBlock Text=&quot;Acceso&quot;\n                               Foreground=&quot;DarkGray&quot;\n                               FontSize=&quot;10&quot;\n                               FontFamily=&quot;Montserrat&quot;\n                               Grid.Column=&quot;0&quot;\n                               VerticalAlignment=&quot;Center&quot;\n                               Margin=&quot;10,0,0,0&quot;\/&gt;\n\n                    &lt;Button x:Name=&quot;btnMinimize&quot;                           \n                            BorderThickness=&quot;0&quot;\n                            Content=&quot;-&quot;\n                            Foreground=&quot;White&quot;\n                            FontSize=&quot;16&quot;\n                            FontFamily=&quot;Montserrat&quot;\n                            Cursor=&quot;Hand&quot;\n                            Grid.Column=&quot;1&quot;\n                            Click=&quot;btnMinimize_Click&quot;&gt;\n\n                        &lt;Button.Style&gt;\n                            &lt;Style TargetType=&quot;Button&quot;&gt;\n                                &lt;Setter Property=&quot;Background&quot; Value=&quot;#28AEED&quot;\/&gt;\n                                &lt;Style.Triggers&gt;\n                                    &lt;Trigger Property=&quot;IsMouseOver&quot; Value=&quot;True&quot;&gt;\n                                        &lt;Setter Property=&quot;Background&quot; Value=&quot;#278BEF&quot;\/&gt;\n                                    &lt;\/Trigger&gt;\n                                &lt;\/Style.Triggers&gt;\n                            &lt;\/Style&gt;\n                        &lt;\/Button.Style&gt;\n\n                        &lt;Button.Template&gt;\n                            &lt;ControlTemplate TargetType=&quot;Button&quot;&gt;\n                                &lt;Border Width=&quot;18&quot; Height=&quot;18&quot;\n                                        CornerRadius=&quot;9&quot;\n                                        Background=&quot;{TemplateBinding Background}&quot;&gt;\n                                    &lt;ContentPresenter VerticalAlignment=&quot;Center&quot;\n                                                      HorizontalAlignment=&quot;Center&quot;\/&gt;\n                                &lt;\/Border&gt;\n                            &lt;\/ControlTemplate&gt;\n                        &lt;\/Button.Template&gt;\n\n                    &lt;\/Button&gt;\n\n                    &lt;Button x:Name=&quot;btnClose&quot;                          \n                            BorderThickness=&quot;0&quot;\n                            Content=&quot;X&quot;\n                            Foreground=&quot;White&quot;\n                            FontSize=&quot;12&quot;\n                            FontFamily=&quot;Montserrat&quot;\n                            Cursor=&quot;Hand&quot;\n                            Grid.Column=&quot;2&quot;\n                            Click=&quot;btnClose_Click&quot;&gt;\n\n                        &lt;Button.Style&gt;\n                            &lt;Style TargetType=&quot;Button&quot;&gt;\n                                &lt;Setter Property=&quot;Background&quot; Value=&quot;#DA34AE&quot;\/&gt;\n                                &lt;Style.Triggers&gt;\n                                    &lt;Trigger Property=&quot;IsMouseOver&quot; Value=&quot;True&quot;&gt;\n                                        &lt;Setter Property=&quot;Background&quot; Value=&quot;#C62DAE&quot;\/&gt;\n                                    &lt;\/Trigger&gt;\n                                &lt;\/Style.Triggers&gt;\n                            &lt;\/Style&gt;\n                        &lt;\/Button.Style&gt;\n\n                        &lt;Button.Template&gt;\n                            &lt;ControlTemplate TargetType=&quot;Button&quot;&gt;\n                                &lt;Border Width=&quot;18&quot; Height=&quot;18&quot;\n                                        CornerRadius=&quot;9&quot;\n                                        Background=&quot;{TemplateBinding Background}&quot;&gt;\n                                    &lt;ContentPresenter VerticalAlignment=&quot;Center&quot;\n                                                      HorizontalAlignment=&quot;Center&quot;\/&gt;\n                                &lt;\/Border&gt;\n                            &lt;\/ControlTemplate&gt;\n                        &lt;\/Button.Template&gt;\n                    &lt;\/Button&gt;\n                &lt;\/Grid&gt;\n\n                &lt;StackPanel Width=&quot;220&quot;\n                            Grid.Row=&quot;1&quot;\n                            Orientation=&quot;Vertical&quot;\n                            Margin=&quot;0,35,0,0&quot;&gt;\n\n                    &lt;Image Source=&quot;\/Images\/Logo.png&quot;\n                           Width=&quot;100&quot; Height=&quot;100&quot;\/&gt;\n\n                    &lt;TextBlock Text=&quot;El Blog de Mota&quot;\n                               Foreground=&quot;White&quot;\n                               FontSize=&quot;25&quot;\n                               FontWeight=&quot;Medium&quot;\n                               FontFamily=&quot;Montserrat&quot;\n                               HorizontalAlignment=&quot;Center&quot;\/&gt;\n\n                    &lt;TextBlock Text=&quot;Aprendiendo a utilizar WPF con un acceso.&quot;\n                               Foreground=&quot;LightGray&quot;\n                               FontSize=&quot;12&quot;\n                               FontWeight=&quot;Medium&quot;\n                               FontFamily=&quot;Montserrat&quot;\n                               TextWrapping=&quot;Wrap&quot;\n                               TextAlignment=&quot;Center&quot;\n                               Margin=&quot;0,5,0,0&quot;\/&gt;\n\n\n                    &lt;TextBlock Text=&quot;Usuario&quot;\n                               Foreground=&quot;DarkGray&quot;\n                               FontSize=&quot;12&quot;\n                               FontWeight=&quot;Medium&quot;\n                               FontFamily=&quot;Montserrat&quot;                             \n                               Margin=&quot;0,35,0,0&quot;\/&gt;\n\n                    &lt;TextBox x:Name=&quot;txtUser&quot;\n                             FontSize=&quot;13&quot;\n                             FontWeight=&quot;Medium&quot;\n                             FontFamily=&quot;Montserrat&quot;                            \n                             Foreground=&quot;White&quot;\n                             CaretBrush=&quot;LightGray&quot;\n                             BorderBrush=&quot;DarkGray&quot;\n                             BorderThickness=&quot;0,0,0,2&quot;\n                             Height=&quot;28&quot;\n                             VerticalContentAlignment=&quot;Center&quot;\n                             Margin=&quot;0,5,0,0&quot;\n                             Padding=&quot;20,0,0,0&quot;&gt;\n\n                        &lt;TextBox.Background&gt;\n                            &lt;ImageBrush ImageSource=&quot;\/Images\/user-icon.png&quot;\n                                        Stretch=&quot;None&quot;\n                                        AlignmentX=&quot;Left&quot;\/&gt;\n                        &lt;\/TextBox.Background&gt;\n                    &lt;\/TextBox&gt;\n\n                    &lt;TextBlock Text=&quot;Password&quot;\n                               Foreground=&quot;DarkGray&quot;\n                               FontSize=&quot;12&quot;\n                               FontWeight=&quot;Medium&quot;\n                               FontFamily=&quot;Montserrat&quot;                             \n                               Margin=&quot;0,15,0,0&quot;\/&gt;\n\n                    &lt;PasswordBox x:Name=&quot;txtPass&quot;\n                             FontSize=&quot;13&quot;\n                             FontWeight=&quot;Medium&quot;\n                             FontFamily=&quot;Montserrat&quot;                            \n                             Foreground=&quot;White&quot;\n                             CaretBrush=&quot;LightGray&quot;\n                             BorderBrush=&quot;DarkGray&quot;\n                             BorderThickness=&quot;0,0,0,2&quot;\n                             Height=&quot;28&quot;\n                             VerticalContentAlignment=&quot;Center&quot;\n                             Margin=&quot;0,5,0,0&quot;\n                             Padding=&quot;20,0,0,0&quot;&gt;\n\n                        &lt;PasswordBox.Background&gt;\n                            &lt;ImageBrush ImageSource=&quot;\/Images\/key-icon.png&quot;\n                                        Stretch=&quot;None&quot;\n                                        AlignmentX=&quot;Left&quot;\/&gt;\n                        &lt;\/PasswordBox.Background&gt;\n                    &lt;\/PasswordBox&gt;\n\n                    &lt;Button x:Name=&quot;btnLogin&quot;                          \n                            BorderThickness=&quot;0&quot;\n                            Content=&quot;Acceder&quot;\n                            Foreground=&quot;White&quot;\n                            FontSize=&quot;12&quot;\n                            FontFamily=&quot;Montserrat&quot;\n                            Cursor=&quot;Hand&quot;                           \n                            Margin=&quot;0,50,0,0&quot;\n                            Click=&quot;btnLogin_Click&quot;&gt;\n\n                        &lt;Button.Style&gt;\n                            &lt;Style TargetType=&quot;Button&quot;&gt;\n                                &lt;Setter Property=&quot;Background&quot; Value=&quot;#462AD8&quot;\/&gt;\n                                &lt;Style.Triggers&gt;\n                                    &lt;Trigger Property=&quot;IsMouseOver&quot; Value=&quot;True&quot;&gt;\n                                        &lt;Setter Property=&quot;Background&quot; Value=&quot;#28AEED&quot;\/&gt;\n                                    &lt;\/Trigger&gt;\n                                &lt;\/Style.Triggers&gt;\n                            &lt;\/Style&gt;\n                        &lt;\/Button.Style&gt;\n\n                        &lt;Button.Template&gt;\n                            &lt;ControlTemplate TargetType=&quot;Button&quot;&gt;\n                                &lt;Border Width=&quot;150&quot; Height=&quot;40&quot;\n                                        CornerRadius=&quot;20&quot;\n                                        Background=&quot;{TemplateBinding Background}&quot;&gt;\n                                    &lt;ContentPresenter VerticalAlignment=&quot;Center&quot;\n                                                      HorizontalAlignment=&quot;Center&quot;\/&gt;\n                                &lt;\/Border&gt;\n                            &lt;\/ControlTemplate&gt;\n                        &lt;\/Button.Template&gt;\n                    &lt;\/Button&gt;\n\n                    &lt;StackPanel Orientation=&quot;Horizontal&quot;\n                                HorizontalAlignment=&quot;Center&quot;\n                                Margin=&quot;0,15,0,0&quot;&gt;\n\n                        &lt;TextBlock Text=&quot;Olvidaste el password?&quot;\n                               Foreground=&quot;DarkGray&quot;\n                               FontSize=&quot;12&quot;\n                               FontWeight=&quot;Medium&quot;\n                               FontFamily=&quot;Montserrat&quot;\/&gt;\n\n                        &lt;TextBlock Text=&quot;Reiniciar&quot;\n                               Foreground=&quot;White&quot;\n                               FontSize=&quot;12&quot;\n                               FontWeight=&quot;Medium&quot;\n                               FontFamily=&quot;Montserrat&quot;\n                               Cursor=&quot;Hand&quot;\n                               Margin=&quot;8,0,0,0&quot;\/&gt;\n\n                    &lt;\/StackPanel&gt;\n\n                &lt;\/StackPanel&gt;\n\n            &lt;\/Grid&gt;\n\n        &lt;\/Border&gt;\n        \n    &lt;\/Border&gt;\n\n&lt;\/Window&gt;\n\n<\/pre><\/div>\n\n\n<p>4. Modificar el archivo<strong> App.xaml<\/strong> para que la aplicaci\u00f3n pueda ejecutar como pagina de inicio, la nueva ventana que acabamos de crear. En este caso modificamos la etiqueta StartupUri y la apuntamos a nuestro archivo LoginView.xaml<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"539\" src=\"https:\/\/jlmota.net\/wp-content\/uploads\/2024\/04\/image-1-1024x539.png\" alt=\"\" class=\"wp-image-27\" srcset=\"https:\/\/jlmota.net\/wp-content\/uploads\/2024\/04\/image-1-1024x539.png 1024w, https:\/\/jlmota.net\/wp-content\/uploads\/2024\/04\/image-1-300x158.png 300w, https:\/\/jlmota.net\/wp-content\/uploads\/2024\/04\/image-1-768x405.png 768w, https:\/\/jlmota.net\/wp-content\/uploads\/2024\/04\/image-1-1536x809.png 1536w, https:\/\/jlmota.net\/wp-content\/uploads\/2024\/04\/image-1-1140x600.png 1140w, https:\/\/jlmota.net\/wp-content\/uploads\/2024\/04\/image-1.png 1919w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Dejo el siguiente link para descargar el proyecto de GitHub.<\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/Instituto-Tecnologico-de-la-Laguna\/WPF-LoginForm.git\">https:\/\/github.com\/Instituto-Tecnologico-de-la-Laguna\/WPF-LoginForm.git<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Windows Presentation Foundation&nbsp;(WPF) es una&nbsp;tecnolog\u00eda&nbsp;de&nbsp;Microsoft, presentada como parte de&nbsp;Windows Vista. Permite el desarrollo de interfaces de interacci\u00f3n en Windows tomando caracter\u00edsticas de&nbsp;aplicaciones&nbsp;Windows y de&nbsp;aplicaciones web. WPF ofrece una amplia infraestructura y potencia gr\u00e1fica con la que es posible desarrollar aplicaciones visualmente atractivas, con facilidades de interacci\u00f3n que incluyen&nbsp;animaci\u00f3n,&nbsp;v\u00eddeo,&nbsp;audio,&nbsp;documentos, navegaci\u00f3n o gr\u00e1ficos&nbsp;3D. Separa, con el lenguaje [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-22","post","type-post","status-publish","format-standard","hentry","category-programacion"],"_links":{"self":[{"href":"https:\/\/jlmota.net\/index.php\/wp-json\/wp\/v2\/posts\/22","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jlmota.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jlmota.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jlmota.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jlmota.net\/index.php\/wp-json\/wp\/v2\/comments?post=22"}],"version-history":[{"count":4,"href":"https:\/\/jlmota.net\/index.php\/wp-json\/wp\/v2\/posts\/22\/revisions"}],"predecessor-version":[{"id":28,"href":"https:\/\/jlmota.net\/index.php\/wp-json\/wp\/v2\/posts\/22\/revisions\/28"}],"wp:attachment":[{"href":"https:\/\/jlmota.net\/index.php\/wp-json\/wp\/v2\/media?parent=22"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jlmota.net\/index.php\/wp-json\/wp\/v2\/categories?post=22"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jlmota.net\/index.php\/wp-json\/wp\/v2\/tags?post=22"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}