Bind Collection to StackPanel

Alright I have figured it out… Using an ItemsControl solved the problem… <ItemsControl x:Name=”tStack” Grid.Column=”0″> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <StackPanel Orientation=”Horizontal”/> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ItemsControl.ItemTemplate> <DataTemplate> <Button Content=”{Binding ItemName}”/> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl>

Android – DataBinding – How and when the Binding classes will be generated?

What is your layout name? The above layout file was activity_main.xml so the generate class was ActivityMainBinding. What this means is that the generated class name will depend on your layout’s name activity_main.xml -> ActivityMainBinding.java I think your activity name is “main_activity”, so the generated binding class name should be MainActivityBinding not ActivityMainBinding

How can I data bind a list of strings to a ListBox in WPF/WP7?

If simply put that your ItemsSource is bound like this: YourListBox.ItemsSource = new List<String> { “One”, “Two”, “Three” }; Your XAML should look like: <ListBox Margin=”20″ Name=”YourListBox”> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Orientation=”Horizontal”> <TextBlock Text=”{Binding}” /> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox> Update: This is a solution when using a DataContext. Following code is the viewmodel you will be … Read more

android data binding with a custom view

In your Custom View, inflate layout however you normally would and provide a setter for the attribute you want to set: private MyCustomViewBinding mBinding; public MyCustomView(…) { … LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); mBinding = MyCustomViewBinding.inflate(inflater); } public void setMyViewModel(MyViewModelObject obj) { mBinding.setMyViewModel(obj); } Then in the layout you use it in: <layout xmlns…> <data> … Read more

How to use data-binding in Dialog?

It is possible to use databinding in a Dialog, first to get the binding working on your Dialog you should inflate it first and pass it to the setContentView like this. DialogOlaBookingConfirmedBinding binding = DataBindingUtil.inflate(LayoutInflater.from(getContext()), R.layout. dialog_ola_booking_confirmed, null, false); setContentView(binding.getRoot()); Then you can pass the viewModel: binding.setViewModel(new ViewModel(this, event.olaBooking)); And now you can see it … Read more