WPF Adventures: Part IV

time to read 14 min | 2674 words

I have made some progress since my last post, I now have removed the TextBlock hacks and am using buttons with replaced UI. The even look nice. I can't figure out how to get accelerator keys to work, I am pretty sure that I am doing everything right, but it doesn't work.

The button:

<Button

      Name="Next"

      Grid.Column="2"

      Click="Next_Click" >

      _Next &gt;&gt;

</Button>

The style (sans some UI stuff to make it shorter):

<Style TargetType="{x:Type Button}" >

      <Setter Property="Cursor"

                  Value="Hand"/>

      <Setter Property="Template">

            <Setter.Value>

                  <ControlTemplate>

                        <Border

                              Background="{StaticResource NormalBrush}"

                              BorderBrush="{StaticResource NormalBorderBrush}">

                              <TextBlock Style="{StaticResource BigText}"

                                             Name="TextField"

                                             Text="{TemplateBinding Property=Button.Content}">

                                    <ContentPresenter RecognizesAccessKey="True"/>

 

                              </TextBlock>

                        </Border>

                        <ControlTemplate.Triggers>

                              <Trigger

                                    Property="Button.IsPressed"

                                    Value="True">

                                    <Setter TargetName="Border"

                                                Property="Background"

                                                Value="{StaticResource PressedBrush}" />

                              </Trigger>

                        </ControlTemplate.Triggers>

                  </ControlTemplate>

            </Setter.Value>

      </Setter>

</Style>

The way it looks:

(Image from clipboard).png

Another issue that I am not sure how to solve is putting more controls on the navigation bar of the application:

(Image from clipboard).png

I am pretty sure that this involves overriding the style for NavigationWindow and doing something there, but I haven't been able to figure it out yet. The new stuff is in the repository if you feel like looking at it, of course.