XAML C#中的远程RadDatePicker SelectableDateStart绑定值

mwecs4sa  于 2022-12-07  发布在  C#
关注(0)|答案(1)|浏览(134)

SelectedDateStart需要绑定到由另一个DatePicker设置的日期值。我可以获得一个将C#中的字符串日期绑定到xaml datePicker SelectedDateStart属性的示例吗?这是我到目前为止所拥有的xaml

<telerik:RadDatePicker IsInputRestrictedToSelectableDates="True" 
                                       SelectableDateStart="{Binding Path=SetDepartureStartDate,Mode=TwoWay}"
                                       SelectedDate="{Binding Path=ActualDepartureDateLocal, Mode=TwoWay}"  
                                       IsEnabled="{Binding Path=IsActualDepartureDateTimeEditable}" 
                                       TabIndex="7" >
                </telerik:RadDatePicker>
vx6bjr1n

vx6bjr1n1#

想通了!

SelectableDateStart="{Binding Path=SelectableDate}"

使用了下面日期选取器上的绑定和路径。

<telerik:RadDatePicker 
                    SelectedDate="{Binding Path=ActualDepartureDateLocal, Mode=TwoWay}"  IsEnabled="{Binding Path=IsActualDepartureDateTimeEditable}" TabIndex="7"  SelectableDateStart="{Binding Path=SelectableDate}" >
                    <i:Interaction.Behaviors>
                        <commanding:UpdateBindingSourceWhenRadDateTimeControlTextChanged/>
                    </i:Interaction.Behaviors>
                </telerik:RadDatePicker>

然后绑定路径被连接到我的cs文件中的DateTime。我遇到的问题是绑定没有连接到我的cs文件的DataContext,并且没有返回DateTime而是返回一个字符串。切换这些,它工作了!

public DateTime SelectableDate
    {
        get
        {
            if (_loadStopToComplete.Actual_Arrival_Local != null)
            {
                _selectedDate = _loadStopToComplete.Actual_Arrival_Local.Value.Date;
                DepartureDate = Convert.ToString(_loadStopToComplete.Actual_Arrival_Local.Value.Date);
            }
            return _selectedDate;
        }
    }

相关问题