Richtextbox wpf binding

There is a much easier way! You can easily create an attached DocumentXaml (or DocumentRTF) property which will allow you to bind the RichTextBox‘s document. It is used like this, where Autobiography is a string property in your data model: <TextBox Text=”{Binding FirstName}” /> <TextBox Text=”{Binding LastName}” /> <RichTextBox local:RichTextBoxHelper.DocumentXaml=”{Binding Autobiography}” /> Voila! Fully bindable … Read more

Should I bind to ICollectionView or ObservableCollection

You always bind to an ICollectionView, whether you make it explicit or not. Assume that we have var collection = new ObservableCollection<string>(); var collectionView = CollectionViewSource.GetDefaultView(collection); In this case, binding to collection or to collectionView is one and the same: the binding engine will bind to the default collection view (which is reference equal to … Read more

Render value without data-binding

Angular 1.3+ In 1.3, Angular has supported this using the following syntax. <div>{{::message}}</div> As mentioned in this answer. Angular 1.2 and below This is simple and doesn’t need a plugin. Check this out. This small directive will easily accomplish what you are trying to achieve app.directive(‘bindOnce’, function() { return { scope: true, link: function( $scope … Read more

Angular2 Component @Input two way binding

For [(toggled)]=”…” to work you need @Input() toggled: boolean; @Output() toggledChange: EventEmitter<boolean> = new EventEmitter<boolean>(); changeValue() { this.toggled = !(this.toggled); this.toggledChange.emit(this.toggled); } See also Two-way binding [UPDATE] – 25 June 2019 From @Mitch’s comment below: It’s worth noting that the @Output name must be the same as the @Input name, but with Change on the … Read more

OneWayToSource binding from readonly property in XAML

Some research results for OneWayToSource… Option # 1. // Control definition public partial class FlagThingy : UserControl { public static readonly DependencyProperty IsModifiedProperty = DependencyProperty.Register(“IsModified”, typeof(bool), typeof(FlagThingy), new PropertyMetadata()); } <controls:FlagThingy x:Name=”_flagThingy” /> // Binding Code Binding binding = new Binding(); binding.Path = new PropertyPath(“FlagIsModified”); binding.ElementName = “container”; binding.Mode = BindingMode.OneWayToSource; _flagThingy.SetBinding(FlagThingy.IsModifiedProperty, binding); Option # … Read more

databind the Source property of the WebBrowser in WPF

The problem is that WebBrowser.Source is not a DependencyProperty. One workaround would be to use some AttachedProperty magic to enable this ability. public static class WebBrowserUtility { public static readonly DependencyProperty BindableSourceProperty = DependencyProperty.RegisterAttached(“BindableSource”, typeof(string), typeof(WebBrowserUtility), new UIPropertyMetadata(null, BindableSourcePropertyChanged)); public static string GetBindableSource(DependencyObject obj) { return (string) obj.GetValue(BindableSourceProperty); } public static void SetBindableSource(DependencyObject obj, string … Read more

Bind to a method in WPF?

Another approach that might work for you is to create a custom IValueConverter that takes a method name as a parameter, so that it would be used like this: ItemsSource=”{Binding Converter={StaticResource MethodToValueConverter}, ConverterParameter=”GetChildren”}” This converter would find and invoke the method using reflection. This requires the method to not have any arguments. Here’s an example … Read more