I have the following:
<ListView Name="lstStepTargets" Margin="0,3,0,-3" VerticalAlignment="Stretch" >
<ListView.View>
<GridView>
<GridViewColumn Header="Enabled" >
<GridViewColumn.CellTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding Path=Enabled, Mode=TwoWay}" HorizontalAlignment="Center"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="TargetPath" >
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBox Width="auto" Text="{Binding Path=BaseFolder}" HorizontalAlignment="Stretch"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="IgnoreFilter" >
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBox Text="{Binding Path=IgnoreFilter}" Name="txtIgnore" MinWidth="100" Width="Auto"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="IncludeFilter" >
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBox Text="{Binding Path=IncludeFilter}" Name="txtInclude" MinWidth="100" Width="Auto"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Apply Filter to All" >
<GridViewColumn.CellTemplate>
<DataTemplate>
<Button Content="Apply" Click="ButtonClick" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
In the handler for the button I need an elegant way to get access to:
A. The text in txtIgnore and txtInclude for "this" row.
B. The data context for "this" row. (I may just need this one)
Any ideas folks?
DataContextis inherited, hence you should be able to get the DataContext of the row from the button:The
MyData-object should have the values you input in the TextBoxes in the propertiesIgnoreFilterandIncludeFiltersince you bound those.