Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1325
Persisting fields width (custom solution)
posted

Hi. I need to write custom logic for persisting fields width. It's a pity but there is no event (or I didn't find it) in XamDataGrad such as FieldResized or something like this. But, I've found a solution from Josh Smith (it's here ). It works fine but has one drawback: if you enable FieldChooser for a grid, open it and try to resize its width then width of the fields in grid also changes. Is there any alternative solution for listening to the field width change or how could be this one fixed?

  • 1325
    Offline posted

    The only solution I've found is:

     

     

    protected override void OnFieldChooserOpening(FieldChooserOpeningEventArgs args)
    {
           Style fieldChooserLabelPresenterStyle FieldChooserLabelPresenterStyle = new Style(typeof                                                                                                                                (LabelPresenter));
          fieldChooserLabelPresenterStyle.Setters.Add(new EventSetter(SizeChangedEvent,
                                                                                              new SizeChangedEventHandler((s, e) => { })));


          args.FieldChooser.Resources.Remove(typeof (LabelPresenter));
          args.FieldChooser.Resources.Add(typeof (LabelPresenter), fieldChooserLabelPresenterStyle);

         base.OnFieldChooserOpening(args);
    }