0

我有以下场景,我想在运行时更改StringFormata 。DataGridTextColumn在我的DataGrid我也DataGridTemplate有一个Button里面。当我按下时,Button我想将StringFormat小数点后两位更改为零小数位。我怎样才能做到这一点?我已经尝试过使用StylesDynamic Resources但到目前为止没有任何效果。此代码发生在我的AutogenerateColumns-Event 中。DGC 是当前列。

DataTrigger t = new DataTrigger();
                        t.Binding = new Binding("Weight");
                        t.Value = 0;
                        Setter s = new Setter();
                        s.Property = DataGridCell.ContentStringFormatProperty;
                        s.Value = new Binding(null) { StringFormat = "N02" };
                        t.Setters.Add(s);

                        Sty.Triggers.Add(t);
                        DGC.CellStyle = Sty;
4

0 回答 0