Add Handler For Child Control Event
WPF
1
Posts
1
Posters
30
Views
1
Watching
-
This is a bit long, but it should be easy to understand... I created a simple navigation CustomControl, with Today, Previous, and Next buttons. It has a routed event called NavigationSelectedEvent. The event is called from the three button's comands: Style
<Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type views:NavigationView}"> <Border x:Name="border" Background="{StaticResource brushActiveBack}" BorderBrush="{StaticResource brushPeriodBorder}" BorderThickness="1,1,0,0" Margin="{Binding Margin, RelativeSource={RelativeSource TemplatedParent}}" Padding="{Binding Padding, RelativeSource={RelativeSource TemplatedParent}}"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/> </Grid.ColumnDefinitions> <Button Grid.Column="0" Content="Today" Height="28" Width="85" Margin="2,2,2,2" Command="{Binding NavigateTodayCommand, RelativeSource={RelativeSource TemplatedParent}}"/> <Button Grid.Column="1" Content="<" Height="28" Width="85" Margin="0,2,2,2" Command="{Binding NavigatePreviousCommand, RelativeSource={RelativeSource TemplatedParent}}"/> <Button Grid.Column="2" Content=">" Height="28" Width="85" Margin="0,2,2,2" Command="{Binding NavigateNextCommand, RelativeSource={RelativeSource TemplatedParent}}"/> </Grid> </Border> </ControlTemplat</x-turndown>