private void bind(PropertyItem propertyItem, RadioButton btnTopLeft, Anchor anchor) { BindingOperations.SetBinding(btnTopLeft, ToggleButton.IsCheckedProperty, LambdaBinding.New( new Binding("Value") { Source = propertyItem, Mode = propertyItem.IsReadOnly ? BindingMode.OneWay : BindingMode.TwoWay }, (object source) => { return((Anchor)source == anchor); }, (bool source) => { return(source ? anchor : Binding.DoNothing); } )); }
public FrameworkElement ResolveEditor(PropertyItem propertyItem) { BindingOperations.SetBinding(ctCombo, ComboBox.SelectedItemProperty, LambdaBinding.New( new Binding("Value") { Source = propertyItem, Mode = propertyItem.IsReadOnly ? BindingMode.OneWay : BindingMode.TwoWay }, (ExtraPropertyId source) => { return(App.DataSources.FirstOrDefault(d => d.PropertyId.Equals(source))); }, (DataSourceInfo source) => { return(source == null ? null : source.PropertyId); } )); return(this); }
public FrameworkElement ResolveEditor(PropertyItem propertyItem) { BindingOperations.SetBinding(textbox, TextBox.TextProperty, LambdaBinding.New( new Binding("Value") { Source = propertyItem, Mode = propertyItem.IsReadOnly ? BindingMode.OneWay : BindingMode.TwoWay }, (Filename source) => { return((string)source); }, (string source) => { return((Filename)source); } )); _expression = textbox.GetBindingExpression(TextBox.TextProperty); return(this); }
public static IEnumerable <TItem> ShowCheckList <TItem>(Window owner, IEnumerable <CheckListItem <TItem> > items, string prompt, string okButton, string[] columnTitles, string promptSure = null) { var wnd = new CheckListWindow() { Owner = owner }; wnd.ctPrompt.Text = prompt; wnd.ctOkBtn.Text = okButton; wnd.ctCancelBtn.Text = App.Translation.Prompt.Cancel; for (int i = 0; i < columnTitles.Length; i++) { wnd.ctGrid.Columns[i + 1].Header = columnTitles[i]; wnd.ctGrid.Columns[i + 1].Visibility = Visibility.Visible; if (i != columnTitles.Length - 1) // mark all columns except for the last one as auto width { wnd.ctGrid.Columns[i + 1].Width = DataGridLength.Auto; } } wnd._promptSure = promptSure; wnd._promptSureYes = okButton.Replace('_', '&'); wnd._checkItems = new ObservableCollection <CheckListItem>(items); wnd.ctGrid.ItemsSource = wnd._checkItems; BindingOperations.SetBinding(wnd.chkSelectAll, CheckBox.IsCheckedProperty, LambdaBinding.New( new Binding { Source = wnd._checkAll, Path = new PropertyPath("Value") }, (bool?checkAll) => checkAll, (bool?checkAll) => { wnd.setAllCheckboxes(checkAll); return(checkAll); } )); if (wnd.ShowDialog() != true) { return(Enumerable.Empty <TItem>()); } return(wnd._checkItems.OfType <CheckListItem <TItem> >().Where(cli => cli.IsChecked).Select(cli => cli.Item)); }