Ich habe ein UserControl in Form einer Toolbar erstellt:
Dem Control sind hier drei Button hinterlegt; pos; pos2; pos3
Wenn das Control sich in einem z.B. Window befindet möchte jedem Button ein separates Ereignes zuweisen können...aber wie geht das?
XML-Quellcode
- <UserControl x:Class="Toolbar_UserControl1"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:local="clr-namespace:CLIENTVISION"
- mc:Ignorable="d"
- xmlns:mycontrol="clr-namespace:CLIENTVISION">
- <ToolBarTray Style="{DynamicResource ToolBarTrayStyle1}">
- <ToolBar Band="1" Style="{DynamicResource ToolbarStyle1}">
- <ToolBar.Resources>
- <Style TargetType="Button">
- <Setter Property="Margin" Value="0"/>
- <Setter Property="IsEnabled" Value="True"/>
- </Style>
- <Style TargetType="Image">
- <Setter Property="Cursor" Value="Hand"/>
- </Style>
- <Style TargetType="Border">
- <Setter Property="BorderBrush" Value="Gray"/>
- <Setter Property="BorderThickness" Value="1"/>
- <Setter Property="CornerRadius" Value="1"/>
- <Setter Property="Margin" Value="3"/>
- </Style>
- </ToolBar.Resources>
- <!--Pos 1-->
- <Border>
- <Button x:Name="pos1" Click="ToolBarButton_Click">
- <Image Source="/CLIENTVISION;component/images/png/058.png"/>
- <Button.ToolTip>
- <mycontrol:ToolTip_UserControl ToolTip="Status des Datensatzes"/>
- </Button.ToolTip>
- </Button>
- </Border>
- <!--Pos 2-->
- <Border>
- <Button x:Name="pos2" Click="ToolBarButton_Click">
- <Image Source="/CLIENTVISION;component/images/png/053.png"/>
- <Button.ToolTip>
- <mycontrol:ToolTip_UserControl ToolTip="Reports und Formulare"/>
- </Button.ToolTip>
- </Button>
- </Border>
- <!--Pos 3-->
- <Border>
- <Button Name="pos3" Click="ToolbarButton_Click">
- <Image Source="/CLIENTVISION;component/images/png/011.png"/>
- <Button.ToolTip>
- <mycontrol:ToolTip_UserControl ToolTip="Vorgang anlegen"/>
- </Button.ToolTip>
- </Button>
- </Border>
- </ToolBar>
- </ToolBarTray>
Dem Control sind hier drei Button hinterlegt; pos; pos2; pos3
Wenn das Control sich in einem z.B. Window befindet möchte jedem Button ein separates Ereignes zuweisen können...aber wie geht das?