0
ユーザーが編集できるリストビュー内にテキストボックスがあり、アイテムソースはobervablecollectionです。テキストボックスの値を編集して保存のキャンセルを押したときに、ウィンドウを閉じてもう一度開くと、元の値に戻るべき新しい値が残ります。実際には、リポジトリデータベースから直接データを取り込んでいるので、なぜ元の値に戻っていないのか分かりません。誰が自分のコードに何が間違っているかを知っていますか?私は何が欠けていますか?ありがとう。 EF用リストビューのテキストボックスの値は、DBに保存されていなくても元の値に戻りません。
public IList<tblContinuingEducationHistory> GetManyNeutralFMContEducHistoryInfobyKeyword(string keyword, string by)
{
try
{
return _continuingEducationHistoryRepository.SelectManyByColumnKeyword(keyword, by);
}
catch (Exception ex)
{
}
return null;
}
リポジトリ:
<ListView Name="lvNeutralEduc" Grid.Column="0" Grid.Row="0" BorderBrush="Transparent" Height="Auto" MaxHeight="300" ScrollViewer.HorizontalScrollBarVisibility="Auto">
<ListView.View>
<GridView>
<GridView.Columns>
<GridViewColumn Header="Family Law Course" Width="Auto" >
<GridViewColumn.CellTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding Path=IsFamilyLawCourse}" HorizontalAlignment="Center" Checked="CheckBox_Checked" Unchecked="CheckBox_Checked" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Course Title" Width="200" >
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBox Text="{Binding Path=ContinuingType, Mode=TwoWay}" Width="200" TextChanged="TextBox_TextChanged" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Course Date" Width="110">
<GridViewColumn.CellTemplate>
<DataTemplate>
<useable:MaskedDatePicker DateValue="{Binding Path=CourseDate, Mode=TwoWay}" Width="110" PreviewTextInput="MaskedDatePicker_PreviewTextInput" GotFocus="MaskedDatePicker_GotFocus" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Course Expiration" Width="110">
<GridViewColumn.CellTemplate>
<DataTemplate>
<useable:MaskedDatePicker DateValue="{Binding Path=CourseExpiration, Mode=TwoWay}" Width="110" PreviewTextInput="MaskedDatePicker_PreviewTextInput"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView.Columns>
</GridView>
</ListView.View>
</ListView>
コードの後ろに:getメソッド移入で
public ObservableCollection<tblContinuingEducationHistory> EducNeutralList
{
get { return _educNeutrallist; }
set
{
if (_educNeutrallist != value)
{
_educNeutrallist = value;
OnPropertyChanged("EducNeutralList");
}
}
}
//constructor
public NeutralContinuingEducHistory(tblNeutralFileMaint currentNeutralFM)
{
isAttyGal = false;
OtherCmdText = "Print Report";
PrintCmdVisibility = Visibility.Visible;
OtherCmdVisibility = Visibility.Collapsed;
AttyGALFormVisibility = Visibility.Collapsed;
ToggleVisibility();
InitializeComponent();
if (currentNeutralFM != null)
{
CurrentNeutralFM = currentNeutralFM;
txtMemberName.Text = CurrentNeutralFM.FullName;
var items = FileMaintenanceBusiness.Instance.GetManyNeutralFMContEducHistoryInfobyKeyword(currentNeutralFM.NeutralID, "NeutralID");//FileMaintenanceBusiness.Instance.GetManyNeutralFMContEducHistoryInfobyKeyword(currentNeutralFM.NeutralID, "NeutralID")!=null ? FileMaintenanceBusiness.Instance.GetManyNeutralFMContEducHistoryInfobyKeyword(currentNeutralFM.NeutralID, "NeutralID") : null);//currentNeutralFM.tblContinuingEducationHistories);
EducNeutralList = items != null ? new ObservableCollection<tblContinuingEducationHistory>(items) : new ObservableCollection<tblContinuingEducationHistory>(CurrentNeutralFM.tblContinuingEducationHistories);
countOrig = EducNeutralList != null ? EducNeutralList.Count : 0;
lvNeutralEduc.ItemsSource = EducNeutralList;
}
this.DataContext = this;
}
ビジネス層
public IList<TEntity> SelectManyByColumnKeyword(string Key, string columnName)
{
// First we define the parameter that we are going to use the clause.
var xParam = Expression.Parameter(typeof(TEntity), typeof(TEntity).Name);
MemberExpression leftExpr = MemberExpression.Property(xParam, columnName);
Expression rightExpr = Expression.Constant(Key);
BinaryExpression binaryExpr = MemberExpression.Equal(leftExpr, rightExpr);
//Create Lambda Expression for the selection
Expression<Func<TEntity, bool>> lambdaExpr =
Expression.Lambda<Func<TEntity, bool>>(binaryExpr,
new ParameterExpression[] { xParam, });
//Searching ....
IList<TEntity> resultCollection = ((IADRRepository<TEntity, TContext>)this).SelectAll
(new Specification<TEntity>(lambdaExpr));
if (null != resultCollection && resultCollection.Count() > 0)
{
//return valid single result
return resultCollection;
}//end if
return null;
}
誰ですか?既にここに詰まっています。解決策を見つけることができません:( – user742102