2010-12-18 31 views
0

您好,我正嘗試在用戶控件內的文本塊上創建點擊文本塊事件,使用主窗口上的buttonbase屬性,但在這裏有 我帶有一個簡單的按鈕, i我不知道做什麼,我會告訴你我的代碼: 這是我的用戶控制:單擊usercontrol項目內的標籤上的事件

<Border BorderBrush="Purple" BorderThickness="3" CornerRadius="3" Margin="3" > 
    <DockPanel> 
     <Grid DockPanel.Dock="Left"> 
      <Grid.RowDefinitions> 
       <RowDefinition Height="Auto"/> 
       <RowDefinition Height="Auto"/> 
       <RowDefinition Height="Auto"/> 
       <RowDefinition Height="Auto"/> 
       <RowDefinition Height="Auto"/> 
       <RowDefinition Height="Auto"/> 
      </Grid.RowDefinitions> 
      <Grid.ColumnDefinitions> 
       <ColumnDefinition Width="Auto"/> 
       <ColumnDefinition Width="120"/> 
      </Grid.ColumnDefinitions> 
      <Label Foreground="Blue">Message Number:</Label> 
      <Label Foreground="Blue" Grid.Row="1">Title:</Label> 
      <Label Foreground="Blue" Grid.Row="2">Message Date:</Label> 
      <Label Foreground="Blue" Grid.Row="3">Contact Mail:</Label> 
      <Label Foreground="Blue" Grid.Row="4">Message Type:</Label> 
      <Label Foreground="Blue" Grid.Row="5">Message Details:</Label> 
      <Label x:Name="lblMessageNum" Grid.Column="1"></Label> 
      <Label x:Name="lblTitle" Grid.Column="1" Grid.Row="1"></Label> 
      <Label x:Name="lblMessageDate" Grid.Column="1" Grid.Row="2"></Label> 
      <Label x:Name="lblContactMail" Grid.Column="1" Grid.Row="3"></Label> 
      <Label x:Name="lblMessageType" Grid.Column="1" Grid.Row="4"></Label> 
      <Label x:Name="lblMessageDetails" Grid.Column="1" Grid.Row="5"></Label> 
     </Grid> 
     <Grid> 
      <Grid.RowDefinitions> 
       <RowDefinition Height="Auto"/> 
       <RowDefinition Height="Auto"/> 
      </Grid.RowDefinitions> 
      <TextBlock Margin="23,0,0,0" x:Name="tbkRemove"> 
       <Underline>Remove Message</Underline> 
       <TextBlock.Style> 
        <Style TargetType="TextBlock"> 
         <Setter Property= "Foreground" Value="Blue"/> 
         <Style.Triggers> 
          <Trigger Property ="IsMouseOver" Value="True"> 
           <Setter Property= "Foreground" Value="Red"/> 
          </Trigger> 
         </Style.Triggers> 
        </Style> 
       </TextBlock.Style> 
      </TextBlock> 
      <Border Grid.Row="1" BorderBrush="Purple" CornerRadius="3" BorderThickness="3" Margin="23,10,6,0"> 
       <Image x:Name="ImgPic" Width="102" Height="110"></Image> 
      </Border> 


     </Grid> 
    </DockPanel> 
</Border> 

這個用戶控件我有tbkRemove文本塊裏面應該有一個事件來刪除它自身(在所有的用戶控件)內從主窗口,所以點擊事件的代碼應該在主窗口上,但我怎麼能讓這樣的事件 在此先感謝您的幫助

+1

我想我理解這個問題,但不完全如何處理這個問題。如果你可以添加一些示例代碼來說明你所談論的關於 – 2010-12-18 16:44:03

回答

2

我創建了一個新的按鈕,看起來像使用表情攪拌器的文本塊,所以我可以使用buttonbase進行泡泡。

+0

好簡單選項的Button示例,這可能會有所幫助。 – 2011-02-22 21:28:58

相關問題