为什么这个列表框在Windows XP而不是Vista或Windows 7上崩溃,
它构建良好没有错误,但当我试图在崩溃的xp中运行它,我得到这个错误.. System.FormatExeption
<ListBox Name="lvMyAssignments" ScrollViewer.VerticalScrollBarVisibility="Hidden" Height="280" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListBox.ItemTemplate>
<DataTemplate>
<Button Margin="0,3,0,0" Tag="{Binding Path=Plocklista}" Background="Transparent" Click="Open_Assignment">
<StackPanel>
<Border BorderBrush="Black" BorderThickness="1,1,1,0">
<Border.Style>
<Style>
<Style.Triggers>
<DataTrigger Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ListBoxItem}}}" Value="True">
<Setter Property="Border.Height" Value="100"/>
<Setter Property="Border.Background">
<Setter.Value>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0" MappingMode="RelativeToBoundingBox">
<GradientStop Color="DarkGray" Offset="1"/>
<GradientStop Color="#FFE8E8E8"/>
<GradientStop Color="#FFBDBDBD" Offset="0.153"/>
<GradientStop Color="DarkGray" Offset="0.904"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
<Border.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0" MappingMode="RelativeToBoundingBox">
<GradientStop Color="#FFECECEC" Offset="1"/>
<GradientStop Color="#FFE8E8E8"/>
<GradientStop Color="#FFBDBDBD" Offset="0.153"/>
<GradientStop Color="#FFE8E8E8" Offset="0.904"/>
</LinearGradientBrush>
</Border.Background>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<Border BorderBrush="Darkgray" BorderThickness="0,0,1,0">
<DockPanel Width="555">
<ItemsControl Height="70" ItemsSource="{Binding Path=Descriptions}" Background="Transparent" BorderThickness="0" >
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock FontWeight="Bold" Text="{Binding Path=Value}"/>
<TextBlock FontWeight="Bold" Margin="5,0,0,0" Text="{Binding Path=Key}"/>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</DockPanel>
</Border>
<StackPanel HorizontalAlignment="Center">
<StackPanel.Background>
<LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
<LinearGradientBrush.RelativeTransform>
<TransformGroup>
<TranslateTransform X="-0.5" Y="-0.5"/>
<ScaleTransform ScaleX="1" ScaleY="1"/>
<SkewTransform AngleX="0" AngleY="0"/>
<RotateTransform Angle="90"/>
<TranslateTransform X="0.5" Y="0.5"/>
<TranslateTransform X="0" Y="0"/>
</TransformGroup>
</LinearGradientBrush.RelativeTransform>
<GradientStop Color="sc#1, 1, 0.158960834, 0.004391442" Offset="0"/>
<GradientStop Color="sc#1, 1, 0.5, 0.5" Offset="1"/>
</LinearGradientBrush>
</StackPanel.Background>
<StackPanel HorizontalAlignment="Center">
<StackPanel.Background>
<LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
<LinearGradientBrush.RelativeTransform>
<TransformGroup>
<TranslateTransform X="-0.5" Y="-0.5"/>
<ScaleTransform ScaleX="1" ScaleY="1"/>
<SkewTransform AngleX="0" AngleY="0"/>
<RotateTransform Angle="90"/>
<TranslateTransform X="0.5" Y="0.5"/>
<TranslateTransform X="0" Y="0"/>
</TransformGroup>
</LinearGradientBrush.RelativeTransform>
<GradientStop Color="sc#1, 1, 0.158960834, 0.004391442" Offset="0"/>
<GradientStop Color="sc#1, 1, 0.5, 0.5" Offset="1"/>
</LinearGradientBrush>
</StackPanel.Background>
<TextBlock Text="{Binding Path=Antal}" TextAlignment="Center" Width="100" FontSize="44pt" FontFamily="Calibri"/>
</StackPanel>
</StackPanel>
</StackPanel>
</Border>
</StackPanel>
</Button>
</DataTemplate>
</ListBox.ItemTemplate>
答案 0 :(得分:1)
我在XAML中看到的唯一可能受操作系统版本影响的是Font="Calibri"
,因为XP将安装与Vista / Win7不同的字体,并且WPF有自己的字体处理。也许就是这样,但可能不是。
我建议您发布您获得的FormatException的堆栈跟踪。这可能会提供一些真实的线索。还要尝试将XAML归结为给出错误所需的最小值。然后我们将更有可能看到它。