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
455
Display Item in a cell using DataTempaltes
posted

Hi,

I have a use case where I need to wrap "Double" as "FractionaDouble" which will enable edit and view doubles as fractions.

I have a XamDataGrid for which certain columns are of the type FractionalDouble. When ever we change the value property of fractionalDouble (which implements INotifyPropertyChanged), the value displayed in the grid does not refresh, we realized that is due to fact that wpf is not refreshing Binding, as the object itself does not change, and the binding in CellValuePresenter is not targeting a specific property within myCustomObject which results in INotifyPropertyChanged to be ineffective.

I attempted to work around the situation by defining a dataTempalte for my customType.


    <DataTemplate DataType="{x:Type Data:FractionalDouble}">
      <StackPanel>
        <TextBlock Text="{Binding Path=AsString,Mode=OneWay Background="Green" Foreground="White"/>
      </StackPanel>
    </DataTemplate>

This did not have any effect as i realized that CellValuePresenter does not have a content presenter / even if it does have one its not referring to the DataTemplates defined in resources.

Second attempt i used override the a ControlTemplate of CellValuePresenter and add a contentPresenter to it. This worked how ever i have read couple of posts which discourage overriding controlTemplate of cellValuePresenter.

So before i start inventing the wheel, wanted to find out if

a) Is this possible using simple dataBinding + any XamDataGrid ./ CellValuePresenter featureto get the above case work

b) Any workaround to force CellValuePresenter to request toString again

c) Will virtualization and other features turn off if I override the template of CellValuePresenter.

d) Can i have a look at the ControlTemplate of CellValuePresenter so that i can make edit / override the required parts only.

Parents
  • 7305
    Suggested Answer
    posted

    Hello Ramakrishna,

    The answers to your questions (A - D):

    A. I would need an example of your custom class that shows the limitation.

    B. You would need to add a property to your object that returned the ToString and then raise ChangeNotificatios when any of the dependent properties chaged. You could then use an UnboundField and set the binding so that you bind to this property. Note this would likely solve the entire issue.

    C. No, but I recommend changing the Template for the editor rather than for CellValuePresenter.

    D. You may take a look at the default style file that is shipped with the product located: C:\Program Files\Infragistics\NetAdvantage 2010.3\WPF\DefaultStyles

    Let me know if you have any question.

    Thank you,
    Sam

Reply Children