caeruleum | Retrofit inspired Http client base on ktor-client | Android library
kandi X-RAY | caeruleum Summary
kandi X-RAY | caeruleum Summary
Retrofit inspired Http client base on ktor-client.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of caeruleum
caeruleum Key Features
caeruleum Examples and Code Snippets
Community Discussions
Trending Discussions on caeruleum
QUESTION
Okay, I'm going to try and explain my excercise now.. This is my PageOverzicht.xaml, and this code works. It gives me a dropdown with the colors of the flowers in (blue, orange, white, ...). Now the datacontext is hardcoded to find the flowers with white color. Goal: set datacontext via code behind, so that the next step can be to use selectionchanged property to select flowers with the selected color.
So now I need to set datacontext first so that it is not hardcoded to white.. Listbox consists out of xml nodes, names of plants that have the color white, using the Page_Loaded method from PageOverzicht.
...ANSWER
Answered 2020-Mar-16 at 16:20The data source handling should be moved to a control which is the common parent of the ComboBox
and the Frame
, in this case I chose the MainWindow
.
You should add the required DependecyProperty
definitions to the MainWindow
which can be used for data binding for the ComboBox.ItemsSource
, ComboBox.SelectedItem
and the Frame.DataContext
.
For the XML handling I replaced the XMLDataProvider with an XElement
data source which allows LINQ To XML in order to comfortably filter or traverse the XML object tree in C#.
Now the ComboBox
binds to a collection of XElement
items representing XML color
nodes. The selected ComboBox
item is a single XML color
element. The descendant plant
nodes of color
are used to set the Frame.DataContext
, which is inherited to the Page.DataContext
. The ListBox
in the Page
now binds its ItemsSource
directly to the DataContext
which is the MainWindow.PlantsOfSelectedColor
property. Alternatively, e.g. if you need to set the Page.DataContext
to something different, you can let the Binding
traverse the visual tree to find the MainWindow.PlantsOfSelectedColor
using RelativeSource FindAncestor
for the Binding.RelativeSource
of ListBox.ItemsSource
.
MainWindow.xaml.cs
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install caeruleum
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page