我目前正在wpf项目中,我必须在其中显示更新客户的日期。所以,我有webservice方法来更新整个客户的信息,但日期不变。我认为字符串格式可能存在问题,但是我已经尝试了所有方法。请帮忙!谢谢!
这是datepicker的xaml代码
<Label Grid.Column="9" Grid.Row="1" VerticalAlignment="Top">
<DatePicker
x:Name="newtally"
Text="{Binding CustomerLastTally}"
Margin="0 0 0 0"
SelectedDateChanged="newtallydate"
/>
</Label>
&这是C#中的Web服务方法
private void newtallydate(object sender, SelectionChangedEventArgs e)
{
webHandler.POS_Update_CustomerAsync(
int.Parse(selected.Customerid),
selected.CustomerName,
Decimal.Parse(selected.Customerbalance),
selected.CustomerLocation,
selected.CustomerLastTally,
(selected.Customerphone),
(selected.Customeraddress));
}
使用两种方式绑定。
下面是我的viewmodel类
public class UpdateDateViewModel:INotifyPropertyChanged
{
private DateTime _customerTally;
public UpdateDateViewModel()
{
CustomerLastTally = DateTime.Today.AddDays(-1);
}
public event PropertyChangedEventHandler PropertyChanged;
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
var handler = PropertyChanged;
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
}
public DateTime CustomerLastTally
{
get { return _customerTally; }
set
{
if (_customerTally != value)
{
_customerTally = value;
updateWebservice();
OnPropertyChanged("CustomerLastTally");
}
}
}
private void updateWebservice()
{
}
}
这是视图代码。
<Grid>
<DatePicker
x:Name="newtally"
Text="{Binding CustomerLastTally,Mode=TwoWay}"
Margin="0 0 0 0"
/>
</Grid>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句