Style
我的 XAML 文件中有配置:
<Style x:Key="CostEstimatesDataGridRowStyle" TargetType="controls:DataGridRow" BasedOn="{StaticResource ReportDataGridRowStyle}">
<Style.Triggers>
<DataTrigger Value="True" >
<DataTrigger.Binding>
<MultiBinding Converter="{x:Static controls:Converters.AndValueConverter}">
<Binding Path="IsEmpty"/>
<Binding Path="IsPrinting">
<Binding.RelativeSource>
<RelativeSource
Mode="FindAncestor"
AncestorType="{x:Type controls:SinglePageReport}"
/>
</Binding.RelativeSource>
</Binding>
</MultiBinding>
</DataTrigger.Binding>
<Setter Property="Visibility" Value="Collapsed"/>
</DataTrigger>
</Style.Triggers>
</Style>
这种风格适用于DataTemplate
:
<DataTemplate x:Key="EstimateGridTemplate">
<GroupBox Header="{Binding Path=Category.Category}">
<GroupBox.Content>
<Grid>
<controls:DataGrid
ItemsSource="{Binding Path=Estimates}"
ItemContainerStyle="{StaticResource CostEstimatesDataGridRowStyle}">
</Grid>
</GroupBox.Content>
</GroupBox>
</DataTemplate>
我的问题是如何以IsPrinting
编程方式设置值?