Note that there are some explanatory texts on larger screens.

plurals
  1. PODataGridTextColumn showing/editing time only, date bound to property of parent usercontrol
    primarykey
    data
    text
    <p>I have a <code>DataGrid</code> within a <code>UserControl</code>. I want to have a <code>DataGridTextColumn</code> bound to a <code>DateTime</code> field, showing only the time. When the user enters a time, the date portion (year, month, day) should be taken from a property (<code>AttendDate</code>) on the <code>UserControl</code>.</p> <p>My first thought was to bind the user control's property to <code>ConverterParameter</code>:</p> <pre><code>&lt;DataGridTextColumn Header="From" Binding="{Binding FromDate, Converter={StaticResource TimeConverter},ConverterParameter={Binding AttendDate,ElementName=UC}}" /&gt; </code></pre> <p>but <code>ConverterParameter</code> doesn't take a binding. I then thought to do this using a <code>MultiBinding</code>:</p> <pre><code>&lt;DataGridTextColumn Header="משעה" Binding="{Binding FromDate, Converter={StaticResource TimeConverter}}" /&gt; &lt;DataGridTextColumn.Binding&gt; &lt;MultiBinding Converter="{StaticResource TimeConverter}"&gt; &lt;Binding Path="FromDate" /&gt; &lt;Binding Path="AttendDate" ElementName="UC" /&gt; &lt;/MultiBinding&gt; &lt;/DataGridTextColumn.Binding&gt; &lt;/DataGridTextColumn&gt; </code></pre> <p>However <code>IMultiValueConverter.Convert</code> -- which takes multiple parameters -- is only called when formatting the display. <code>IMultiValueConverter.ConvertBack</code> which <strong>is</strong> called on editing, only takes one parameter - the entered string.</p> <p>How can I do this?</p> <p>(I am not using MVVM; not something I can change.)</p>
    singulars
    1. This table or related slice is empty.
    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.
    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