2012-06-25 102 views
0

我有一個用戶控件,其中包含具有多個選項卡的選項卡項目。每個選項卡都包含一個具有相同按鈕的自定義堆棧面板(添加,更新,刪除)。我收到「指定的元素已經是另一個元素的邏輯子元素,先斷開它」的錯誤。我不確定如何斷開連接,因爲我已經設置了x:Shared = "False"元素。對多個選項卡按鈕使用相同的圖像和按鈕樣式

內Grid.Resource:

<!--ButtonAddImage--> 
<Image x:Key="ButtonAddImage" 
     x:Shared="True"> 
    <Image.Style> 
     <Style TargetType="{x:Type Image}"> 
      <Setter Property="Source" 
        Value="add2_32.png" /> 
      <Setter Property="Stretch" 
        Value="Uniform" /> 
     </Style> 
    </Image.Style> 
</Image> 


<!--ButtonAddStyle--> 
<Style TargetType="Button" 
     x:Key="ButtonAddStyle" 
     x:Shared="False"> 
    <Setter Property="Content" 
     Value="{DynamicResource ResourceKey=ButtonAddImage}" /> 
    <Setter Property="Width" 
      Value="32" /> 
    <Setter Property="Height" 
      Value="22" /> 
    <Setter Property="HorizontalAlignment" 
      Value="Left" /> 
    <Setter Property="VerticalAlignment" 
      Value="Center" /> 
</Style> 

內標籤:

<Button Style="{DynamicResource ResourceKey=ButtonAddStyle}" 
     Name="gdSMSInfo_btnAddRecord" 
     Click="gdSMSInfo_btnAddRecord_Click"> 

回答

0

您的X:共享= 「假」 的按鈕樣式,但X:共享= 「真」 爲您在樣式中使用的圖像。將圖像本身上的x:Shared更改爲False,它適用於我。