6
訪問按鈕
我有一個數據網格下面的.xaml和希望顯示在的.cs代碼的.xaml代碼的某些條件/隱藏按鈕,如下如何從DataGridTemplateColumn.CellTemplate
<DataGridTemplateColumn Header="Action" Width="auto" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Button x:Name="btnConfirm" Content="Confirm" Click="ConfirmButton_Click" Height="auto" Width="auto" Opacity="100" Background="Transparent" BorderBrush="Transparent" HorizontalAlignment="Left"/>
<Button x:Name="btnDecline" Content="Decline" Click="btnDecline_Click" Height="auto" Width="auto" Opacity="100" Background="Transparent" BorderBrush="Transparent" HorizontalAlignment="Left" />
<Button x:Name="btnCancel" Content="Cancel" Click="btnCancel_Click" Height="auto" Width="auto" Opacity="100" Background="Transparent" BorderBrush="Transparent" HorizontalAlignment="Left"/>
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
和的.cs代碼是
foreach (sp_ProcessingJobsResult item in grdUnConfirmJobs.ItemsSource)
{
var row = grdUnConfirmJobs.ItemContainerGenerator.ContainerFromItem(item) as System.Windows.Controls.DataGridRow;
if (item.Status == "Cancellation Requested.")
{
//how find control
}
}
我編輯了你的標題。請參閱:「[應該在其標題中包含」標籤「](http://meta.stackexchange.com/questions/19190/)」,其中的共識是「不,他們不應該」。 –
http://stackoverflow.com/questions/19379946/how-to-access-a-control-within-data-template-from-code-behind的可能重複 – Ahmad