WPF UIElements, встроенный с текстом “украшения”

Мне нравится, как Крунослав Захер реализует ActivityIndicator в проекте RxExample в репозитории RxSwift.

https://github.com/ReactiveX/RxSwift/blob/2e64568/RxExample/RxExample/Services/ActivityIndicator.swift

Использование:

let activityIndicator = ActivityIndicator()

let state = githubSearchRepositories(
            searchText: searchBar.rx.text.orEmpty.changed.asSignal().throttle(0.3),
            loadNextPageTrigger: loadNextPageTrigger,
            performSearch: { URL in
                GitHubSearchRepositoriesAPI.sharedAPI.loadSearchURL(URL)
                    .trackActivity(activityIndicator)
})

[119 ] Таким образом, в вашем случае вы можете реализовать другую наблюдаемую информацию, аналогичную ActivityIndicator

let operationProgress = OperationProgress()

Observable.from([1,2,3,4])
    .flatMap { queryApi([111]).updateProgress(operationProgress, to: .step1) }
    .flatMap { queryApi2([111]).updateProgress(operationProgress, to: .step2) }
    .flatMap { queryApi3([111]).updateProgress(operationProgress, to: .step3) }

Я не знаю, подходит ли это вашей ситуации, но, по крайней мере, она отделяет вашу логику прогресса от наблюдаемой операции. [ 1110]

7
задан Dave Clemmer 21 August 2013 в 03:44
поделиться

1 ответ

Смотрите на InlineUIContainer и BlockUIContainer классы. Они позволяют UIElements, чтобы быть встроенным в содержание потока, как FlowDocument или TextBlock.

Вот пример Кнопки, встроенной в a TextBlock:

<TextBlock>
    Some inline
    <InlineUIContainer>
        <Button Content="Hi" Click="Button_Click" />
    </InlineUIContainer>
    inside the text.
</TextBlock>
13
ответ дан 6 December 2019 в 19:42
поделиться
Другие вопросы по тегам:

Похожие вопросы: