binding

How to create converter to work like “FindAncestor” for checking IsTypeFound?

随声附和 提交于 2019-12-23 05:34:06
问题 I want to create a converter in which I will pass a type to find, in element's parent hierarchy & it should return true if such a type found, otherwise false. So far, I tried below given code & it is working. but now only i have issue is it finds element parent hierarchy until element's parent is null. I want to give ancestor level for finding element in parent hierarchy. So How can I give Ancestor Level to converter?? I used LayoutHelper.cs Class to find element in parent hierarchy as given

ListView - select index only programmatically

会有一股神秘感。 提交于 2019-12-23 05:26:21
问题 i am trying to implement listbox (or listview): <ListView ItemsSource="{Binding Players}" SelectedIndex="{Binding SelectedIndex}"> My problem is, that i want to bind selected index to property in code-behind. It work only on form start, but i need to disable user to change selection. Selectin will be changed ONLY programmaticaly. Thanks for all advices or solutions :) 回答1: So, working solution: private void playersList_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (sender

bind different Knockout JS templates inside foreach loop

六月ゝ 毕业季﹏ 提交于 2019-12-23 05:20:12
问题 I am trying to use KO templates to parse a JSON file (see here) into some pretty looking grid layouts.. (think similar to masonry/isotope layouts).. each template section will have different sized rectangles and squares inside it but the overall template conforms to a grid of 5 boxes wide by 3 boxes high (for example) Given this what i have been trying to do is detect the template, then iterate through each item, if its a certain index in the iteration load either the single, double, or

Spring MVC Binding: How to bind ArrayList<…>?

妖精的绣舞 提交于 2019-12-23 05:17:42
问题 I've got a DTO (bean) with ArrayList field: public MyDTO { ... private List<MyThing> things; ... ... getters, setters and so on } In my initBinder I have: @InitBinder public void initBinder(WebDataBinder binder) { ... binder.registerCustomEditor(List.class, "things", new PropertyEditorSupport() { @Override public void setAsText(String text) throws IllegalArgumentException { List<MyThing> things = new ArrayList<MyThings>; // fill things array with data from text ... // On that stage things

Silverlight DataGrid - Binding to a Collection of Collections of objects

我与影子孤独终老i 提交于 2019-12-23 05:16:05
问题 Problem: The data I'm trying to display is essentially a collection of collections of some object. So the rows can be any number, normal for a datagrid, and the columns are also any number. That's not so normal for a datagrid. Usually you have a set number of columns and your rows vary. The datagrid cell will be either a string or a value changeable via a combobox. Attempted Solution: I tried adding columns to the datagrid dynamically, and while this worked just fine (adding them in

error on accessing a property of a control in a wpf user control

雨燕双飞 提交于 2019-12-23 05:15:44
问题 i have created a wpf user control with a text box and a combo box. for accessing the text property of the text box i have used the below code public static readonly DependencyProperty TextBoxTextP = DependencyProperty.Register( "TextBoxText", typeof(string), typeof(TextBoxUnitConvertor)); public string TextBoxText { get { return txtValue.Text; } set { txtValue.Text = value; } } in another project i have used the control and bind the text as below: <textboxunitconvertor:TextBoxUnitConvertor

Data Binding with Timer Implementation

試著忘記壹切 提交于 2019-12-23 05:09:46
问题 Can't figure out why this timer isn't displaying information. Timer rigged to method to update TextBlock in TimeEntry. Binding doesn't seem to work, and I don't understand how to do it properly. I've looked at the MSDN sites. They only give out the basics: not enough. Code: TimeEntry.xaml.cs : public partial class TimeEntry : UserControl { public static readonly DependencyProperty timeSpentProperty = DependencyProperty.Register("timeSpent", typeof(TimeSpan), typeof(TimeEntry), new

Binding issue in custom Xamarin.Forms control

有些话、适合烂在心里 提交于 2019-12-23 04:57:07
问题 I have a strange problem with bindings on a custom control. I created a custom toolbar: public partial class TopToolbar { public static readonly BindableProperty BackCommandProperty = BindableProperty.Create(nameof(BackCommand), typeof(ICommand), typeof(TopToolbar), propertyChanged: BackCommandChanged); public ICommand BackCommand { get => (ICommand) GetValue(BackCommandProperty); set => SetValue(BackCommandProperty, value); } public TopToolbar() { InitializeComponent(); } // for debug

WPF DataTemplate Textblock binding

左心房为你撑大大i 提交于 2019-12-23 03:51:59
问题 I have a listbox of Students and the datatemplate for list item. The DataTemplate has a text block named tb. I want to set this textblock to be binded to Name property. How can I do it in xaml form outside? (Not from the datatemplate) <ListBox ItemsSource="{Binding l}" ItemTemplate="{Binding DataTemplate_L}" Margin="12,70,0,0"> </ListBox> Thank you 回答1: If I understand you correctly, you're asking how you set the databinding for the textblock, that is currently in your DataTemplate? You can't

WPF rectangle color binding

只谈情不闲聊 提交于 2019-12-23 03:48:12
问题 I'm trying to write grid of rectangles, wich does change color of its objects. private void Window_Loaded(object sender, RoutedEventArgs e) { for (int i = 0; i < size; i++) { main_grid.ColumnDefinitions.Add(new ColumnDefinition()); main_grid.RowDefinitions.Add(new RowDefinition()); } for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { cells[i, j] = new Cell { state = false, col = false }; Rectangle rect = new Rectangle(); Grid.SetColumn(rect, j); Grid.SetRow(rect, i); rect.Fill