1
我有一個GridView,我想在其中一列的標題中嵌入一個複選框。我需要檢查它是代碼隱藏的IsChecked屬性。不過,我可以不上名字,因爲它是訪問它的模板列標題象下面這樣:如何在ControlTemplate中聲明時訪問子控件的屬性?
<ListView.View>
<GridView>
<GridViewColumn>
<GridViewColumn.HeaderContainerStyle>
<Style TargetType="{x:Type GridViewColumnHeader}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type GridViewColumnHeader}" >
<Border Background="SkyBlue" BorderBrush="Black" BorderThickness="1,1,0,1">
<CheckBox Name="_cbAllSettingFiles"
Command="{Binding Path=CheckAllLocationFilters}"
CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=IsChecked}"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</GridViewColumn.HeaderContainerStyle>
...
有另一種方式來訪問代碼隱藏的財產器isChecked的價值?或者我首先想到的是錯誤的方式?