Note that there are some explanatory texts on larger screens.

plurals
  1. PODataBinding to Calculated Field
    primarykey
    data
    text
    <p>I'm running into a small problem where I'm trying to bind a DataTextColumn of a DataGrid to a Calculated Field. </p> <p>WPF </p> <pre><code>&lt;DataGrid ItemsSource="{Binding Path=CurrentRoster, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" AutoGenerateColumns="False" AlternatingRowBackground="Gainsboro" AlternationCount="2"&gt; &lt;DataGrid.Columns&gt; &lt;DataGridComboBoxColumn Header="Student Enrolled" ItemsSource="{Binding Source={StaticResource AvailableStudents}}" SelectedItemBinding="{Binding Path=Student}"&gt; &lt;/DataGridComboBoxColumn&gt; &lt;DataGridTextColumn Header="Registration" Binding="{Binding Path=RegistrationCosts, StringFormat='{}{0:C}'}"/&gt; &lt;DataGridTextColumn Header="Lodging" Binding="{Binding Path=LodgingCosts, StringFormat='{}{0:C}'}"/&gt; &lt;DataGridTextColumn Header="Travel" Binding="{Binding Path=TravelCosts, StringFormat='{}{0:C}'}"/&gt; &lt;DataGridTextColumn Header="Dining" Binding="{Binding Path=DiningCosts, StringFormat='{}{0:C}'}"/&gt; &lt;DataGridTextColumn Header="Total Costs" IsReadOnly="True" Binding="{Binding Path=TotalCosts, StringFormat='{}{0:C}'}"/&gt; &lt;/DataGrid.Columns&gt; </code></pre> <p>Where Student is a Entity object with one small addition. TotalCosts isn't a field on the db tables, so I created a partial class for this. </p> <pre><code>public partial class Student { public Decimal TotalCosts { get { return (LodgingCosts + RegistrationCosts + TravelCosts + DiningCosts); } } } </code></pre> <p>The problem I'm experiencing is that TotalCosts is not automatically updating when you fill in any of the other fields. My guess it is because it is not listed as a dependency property. How do I resolve this for a property where there is no set ?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload