2009-08-21 25 views
10

पर बटन का बाध्य कमांड पैरामीटर मेरे पास एक WPF UserControl है जिसमें एक निकालना बटन है, मैं पूरे उपयोगकर्ता नियंत्रण को कमांड पैरामीटर के रूप में पास करना चाहता हूं।wpf usercontrol, पैरेंट उपयोगकर्ता नियंत्रण

वर्तमान में बाध्यकारी कमांड पैरामीटर = "{बाध्यकारी सापेक्ष स्रोत = {सापेक्ष स्रोत स्वयं}} पर सेट है" जो मुझे बटन देता है, लेकिन मैं पूरा नियंत्रण कैसे प्राप्त कर सकता हूं?

क्या कोई भी सहायता कर सकता है?

चीयर्स,

एंडी

<UserControl x:Class="GTS.GRS.N3.Controls.LabelledTextBox" 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> 
<Grid> 
    <Grid.ColumnDefinitions> 
     <ColumnDefinition Width="100" /> 
     <ColumnDefinition Width="155" /> 
     <ColumnDefinition /> 
    </Grid.ColumnDefinitions> 
    <Label Name="label" HorizontalAlignment="Left" Width="96">Label</Label> 
    <TextBox Name="textBox" Grid.Column="1" /> 
    <Button Grid.Column="2" Style="{DynamicResource CloseButton}" Command="{Binding RemoveCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}}" Visibility="{Binding RemoveVisible}"></Button> 
</Grid> 
</UserControl> 

उत्तर

6

यह फटा ...

<Button 
    Grid.Column="2" 
    Style="{DynamicResource CloseButton}" 
    Command="{Binding RemoveCommand}" 
    CommandParameter="{Binding RelativeSource= 
     {RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" 
    Visibility="{Binding RemoveVisible}" 
    /> 
संबंधित मुद्दे