WPF错误 - "为系统提供价值.windows.windows.baml2006.typeconvertermarkupextension'抛出异常。"

时间:2016-09-26 11:21:59

标签: wpf templates data-binding

我添加了DataGrid列,因为我想自己定制它们,如列宽等,之后我开始接收该弹出消息。当我删除<DataGrid.Columns>下的数据时,一切都很好,我不知道为什么会这样。我是WPF的新手,我无法发现错误。

     <Grid.ColumnDefinitions>
        <ColumnDefinition Width="10*" />
    </Grid.ColumnDefinitions>

   <DataGrid Grid.Column="0" CanUserAddRows="False" AutoGenerateColumns="False" Name="datagrid1" Margin="10,128,10,0" Background="Transparent">
      <DataGrid.Columns>
          <DataGridTextColumn Binding="{Binding Path=ProductName}" Header="Product Name"    MinWidth="30"   FontSize="15px" />
          <DataGridTextColumn Binding="{Binding Path=Quantity}"     Header="Quantity"       MinWidth="30"   FontSize="15px" />
          <DataGridTextColumn Binding="{Binding Path=NumberOfOrder}" Header="Order Number"  MinWidth="30"   FontSize="15px" />
          <DataGridTextColumn Binding="{Binding Path=CustomerName}"  Header="Customer"      Width="*"       FontSize="15px" />
      </DataGrid.Columns>
   </DataGrid>

1 个答案:

答案 0 :(得分:0)

FontSizedouble,因此'px'会抛出错误。 尝试将FontSize更改为“15”

<DataGrid.Columns>
    <DataGridTextColumn Binding="{Binding Path=ProductName}" Header="Product Name"    MinWidth="30"   FontSize="15" />
    <DataGridTextColumn Binding="{Binding Path=Quantity}"     Header="Quantity"       MinWidth="30"   FontSize="15" />
    <DataGridTextColumn Binding="{Binding Path=NumberOfOrder}" Header="Order Number"  MinWidth="30"   FontSize="15" />
    <DataGridTextColumn Binding="{Binding Path=CustomerName}"  Header="Customer"      Width="*"       FontSize="15" />
</DataGrid.Columns>