在我的ViewModel中,我有一个ObservableCollection字符串,其中包含从以太网收到的所有消息:
object(EWSType_FindItemType)[2]
public 'CalendarView' =>
object(EWSType_CalendarViewType)[4]
public 'EndDate' => string '2015-06-22T02:00:00+02:00' (length=25)
public 'MaxEntriesReturned' => null
public 'StartDate' => string '2015-06-20T02:00:00+02:00' (length=25)
public 'ContactsView' => null
public 'DistinguishedGroupBy' => null
public 'FractionalPageItemView' => null
public 'GroupBy' => null
public 'IndexedPageItemView' => null
public 'ItemShape' =>
object(EWSType_ItemResponseShapeType)[3]
public 'AdditionalProperties' => null
public 'BaseShape' => string 'Default' (length=7)
public 'BodyType' => null
public 'ConvertHtmlCodePageToUTF8' => null
public 'FilterHtmlContent' => null
public 'IncludeMimeContent' => null
public 'ParentFolderIds' =>
object(EWSType_NonEmptyArrayOfBaseFolderIdsType)[5]
public 'DistinguishedFolderId' =>
object(EWSType_DistinguishedFolderIdType)[6]
public 'ChangeKey' => null
public 'Id' => string 'calendar' (length=8)
public 'Mailbox' => null
public 'FolderId' => null
public 'QueryString' => null
public 'Restriction' => null
public 'SortOrder' => null
public 'Traversal' => string 'Shallow' (length=7)
我用转换器将它绑定到视图中的texbox:
public ObservableCollection<string> Messages { get; set; }
我的转换器很简单
<TextBox Text="{Binding Messages, Converter={StaticResource ListToStringConverter}}" HorizontalAlignment="Center"/>
当我选择一些文本时,如果在我的消息中添加了新消息,则选择会消失。
任何想法如何保持选择?
答案 0 :(得分:1)
您可以通过处理SelectionChanged和TextChanged事件来阻止这种情况。
$pdf = App::make('dompdf.wrapper');
Route::get('/dompdf', function() {
$html='<p>Foo Bar</p>';
PDF::loadHTML($html)->setPaper('a4')
->setOrientation('landscape')
->setWarnings(false)
->save('myfile.pdf');
});
然后,在处理程序中:
<TextBox Text="{Binding Messages,
Converter={StaticResource ListToStringConverter}}"
HorizontalAlignment="Center"
SelectionChanged="TextBox_SelectionChanged"
TextChanged="TextBox_TextChanged" />
这最好在带有附加属性的行为中进行,而不是在代码隐藏中进行,但是你明白了。