问题
I'm having strange issues with a WPF application. I've deployed it under Window Server 2003 and its behavior is different compares to Win7.
For example I have this kind of XAML :
<GroupBox x:Name="groupbox1">
<GroupBox.Style>
<Style BasedOn="{StaticResource {x:Type GroupBox}}" TargetType="{x:Type GroupBox}">
<Style.Triggers>
<DataTrigger Binding="{Binding IsModel, UpdateSourceTrigger=PropertyChanged}" Value="True">
<Setter Property="Visibility" Value="Collapsed" />
</DataTrigger>
</Style.Triggers>
</Style>
</GroupBox.Style>
It works like a charm on Win7, but on Windows Server 2003 it doesn't work at all and my groupbox has always the Visibility property set to Visible.
Some controls like the Expander is also displayed differently.
The configuration of WS 2003 is :
- WS 2003 SP2
- Microsoft .Net Framework 3.5 SP1
If anyone can give me a hint about this issue it would be a great help !
Thanks.
回答1:
I work also on Windows 2003 Server machine. I don't have this issue. I've tried a bit different code in Kaxaml. Try it. If your issue is gone that means the problem with binding to datacontext's property IsModel.
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel>
<CheckBox x:Name="Check" Content="Check it to hide GroupBox" />
<GroupBox x:Name="groupbox1" Header="Group">
<GroupBox.Style>
<Style BasedOn="{StaticResource {x:Type GroupBox}}" TargetType="{x:Type GroupBox}">
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=Check, Path=IsChecked, UpdateSourceTrigger=PropertyChanged}" Value="True">
<Setter Property="Visibility" Value="Collapsed"/>
</DataTrigger>
</Style.Triggers>
</Style>
</GroupBox.Style>
<TextBlock Text="Some GroupBox content" />
</GroupBox>
</StackPanel>
</Page>
来源:https://stackoverflow.com/questions/4730019/wpf-issues-with-windows-server-2003