0

これから変更したい:

 <Style x:Key="ReportLabelColumn" TargetType="TableColumn">
      <Setter Property="Width" Value="120px" />
 </Style>

これに:

 private Style ReportLabelColumn = new Style(typeof(TableColumn));
 ReportLabelColumn.Setters.Add(new Setter(TableColumn.WidthProperty, 120));

しかし、実行しようとすると、次のようなエラーが表示されます。

 {"'120' is not a valid value for the 'System.Windows.Documents.TableColumn.Width' property on a Setter."}

120その値を として受け入れるように、何に変更し120pxますか?

4

1 に答える 1

1

TableColumn.WidthGridLength型プロパティです。GridLengthプロパティを設定するオブジェクトを作成する必要があります。

ReportLabelColumn.Setters.Add(new Setter(TableColumn.WidthProperty, new GridLength(120)));
于 2012-12-06T19:00:59.860 に答える