Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

370
Vistas
Since I'm blind and Visual Studio isn't accessible, can I create C# WPF applications just with plain code?

I am totally blind, I use NVDA screen reader to operate my system, and I am trying to create a Windows desktop application. Visual Studio isn't screen-reader friendly, at least not the forms designer part. VS Code is pretty much accessible, although powershell's protools' designer isn't.

Whenever I see a question about writing GUI in WPF with pure code I find a lot of "why in the name of God would you want to do that? Use VS!" answers. Well, here is the reason, VS form designer is out of reach to blind programmers, so the least practical approach will have to do.

So, can it be done? Would you suggest any resources or approaches to this?

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

Yes. You can do WPF only with code.

Here is a simple example from http://www.java2s.com/Tutorial/CSharp/0470__Windows-Presentation-Foundation/CodeOnlyWPFApplicationSample.htm

using System;
using System.Windows;
using System.Windows.Controls;

  public class App : Application {

    protected override void OnStartup(StartupEventArgs e) {
      base.OnStartup(e);
      MainWindow window = new MainWindow();
      window.Show();
    }

    [STAThread]
    public static void Main()
    {
        App app = new App();
        app.Run();
    }
  }

  public class MainWindow : Window {

    protected override void OnInitialized(EventArgs e) {
      base.OnInitialized(e);
      Button closeButton = new Button();
      closeButton.Content = "Close";
      this.Content = closeButton;
      closeButton.Click += delegate {
        this.Close();
      };
    }
  }

Also, it might be easier to use WinForms since it uses C# as code-behind and less XML.

over 4 years ago · Santiago Trujillo Denunciar

0

I'm going to try and build up from the other example to get you compile-able code. To get WPF working, you'll need a project that builds with WPF support.

The simplest way is to create a .csproj ourself and use the previously posted code-only solution.

So, start with a minimal App.csproj file as so:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net5.0-windows</TargetFramework>
    <UseWPF>true</UseWPF>
  </PropertyGroup>
</Project>

Then the app & window code in App.cs as before. I've added a couple controls to it, as you'll need a container anyway (I used StackPanel) if you want to start adding more stuff later.

using System;
using System.Windows;
using System.Windows.Controls;

public class App : Application {
    protected override void OnStartup(StartupEventArgs e)     {
        base.OnStartup(e);
        new MainWindow().Show();
    }

    [STAThread]
    public static void Main() => new App().Run();
}

public class MainWindow : Window {
    protected override void OnInitialized(EventArgs e) {
        base.OnInitialized(e);

        var panel = new StackPanel();
        this.Content = panel;

        var label = new Label { Content = "Click me:" };
        panel.Children.Add(label);
        
        var closeButton = new Button { Content = "Close", Height = 100 };
        closeButton.Click += (sender, args) => this.Close();
        panel.Children.Add(closeButton);

        (this.Width, this.Height) = (200, 200);
    }
}

You then build the whole project by using dotnet build. And you can run it with dotnet run or invoking the exe directly.

Alternatively, if you'd like to explore a WPF project with separate .xaml and .xaml.cs code, you can create your project using dotnet new wpf -o MyProjectName. This will produce a project, a xaml-based App, and a xaml-based form.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda