DEV Community

John Peters
John Peters

Posted on

WPF A Refresher

My current project may include some WPF work. I had to brush up on it a bit, but love the new hot reload feature.

I always preferred the Dark Theme but couldn't recall how to use it.

Alt Text

Oh yes, the Resource Directory thing.

            <ResourceDictionary Source="Themes\ExpressionDark.xaml" />
Enter fullscreen mode Exit fullscreen mode

This means the project has a themes folder with ExpressionDark.xaml.

Alt Text

But we had to use Nuget to get the theme.

Alt Text

I remember this persons' name from 7 years ago. Glad to see package is still there. Wow! Thanks Stan...

Then I needed to recall the use of StackPanel, Grid, RowDefinition, Button, Label and TextBox.

<StackPanel  Background="#333">      
<Grid  Margin="50,20" >
        <RowDefinition ></RowDefinition>
        <RowDefinition ></RowDefinition>
    <StackPanel Grid.Row="0" Height="30" Orientation="Horizontal" HorizontalAlignment="Left">
        <Button Width="120">Best Article</Button>
        <Button Width="120">Best Project</Button>
        <Button Width="120">GitHub</Button>
        <Button Width="120">StackOverFlow</Button>
        <Button Width="120">MSDN</Button>
        <Button Width="120">Azure</Button>
    <Grid Grid.Row="1" Height="30" Margin="0,10" >
                <ColumnDefinition Width="40"></ColumnDefinition>
                <ColumnDefinition Width="400"></ColumnDefinition>
                <ColumnDefinition Width="150"></ColumnDefinition>
        <Label Grid.Column="0" HorizontalContentAlignment="center" Margin="0,0,20,0">URL</Label>
        <TextBox Grid.Column="1"></TextBox>
        <Button Click="ButtonGo" Margin="15 0 0 0" Grid.Column="2">Go</Button>
Enter fullscreen mode Exit fullscreen mode

Button Click Handlers, Margins and Grid Column Placement

 <Button Click="ButtonGo" Margin="15 0 0 0" Grid.Column="2">
Enter fullscreen mode Exit fullscreen mode

And off we go...


Discussion (0)