2012-02-02 10 views
3

DataGridがあり、DataGridTemplateColumnにチェックを入れると、ElementNameバインディングの助けを借りてコメントのポップアップが開きます。ElementName DataGridTemplateColumnでのバインド

<WpfToolkit:DataGridTemplateColumn> 
          <WpfToolkit:DataGridTemplateColumn.CellTemplate> 
           <DataTemplate> 
            <Grid > 
             <StackPanel Orientation="Vertical"> 
              <ToggleButton Content="C" Name="toggleButon" VerticalAlignment="Center" Background="Transparent"></ToggleButton> 

             <Popup Height="Auto" Width="300" IsOpen="{Binding ElementName=toggleButon,Path=IsChecked}" StaysOpen="True" AllowsTransparency="True"> 
              <Border BorderThickness="2" Background="LightGray"> 
               <StackPanel Margin="20" Orientation="Vertical"> 
                 <TextBlock Text="Bloomberg Run Text Comment" Foreground="Black"></TextBlock> 
                <TextBox Text="check"/> 

               </StackPanel> 
              </Border> 
             </Popup> 
             </StackPanel> 
            </Grid> 
           </DataTemplate> 
          </WpfToolkit:DataGridTemplateColumn.CellTemplate> 
         </WpfToolkit:DataGridTemplateColumn> 

期待どおりに動作します。しかし、理解しているように、ToggleButtonのelementnameは各行で同じであるため、elementNameバインディングがどのようにrowlevelで動作しているのか不思議です。どのようにトグルボタンを押すと、そのスコープ内でのみポップアップウィンドウが開き、他の行にもポップアップウィンドウは表示されません。

答えて

関連する問題