binding

Unable to set ContentTemplate via DataTrigger

自古美人都是妖i 提交于 2020-01-01 05:18:10
问题 I want the ContentTemplate to vary according to the value in the DataTrigger . And yes, I considered using a DataTemplateSelector , but now I need a DataTrigger or better said a MultiDataTrigger . Please take a look at the following sample app, the DataTemplate doesn't change: <Window x:Class="Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:src="clr-namespace:WpfApplication1"> <StackPanel> <CheckBox

Binding image source dynamically on xamarin forms

≡放荡痞女 提交于 2020-01-01 04:38:05
问题 my question is, could I Binding string image to image source ? I have multiple image and the image will change on if condition. So: Xaml on Xamarin forms: <Image Source="{Binding someImage}" Aspect="Fill" Grid.Row="2"></Image> Codebehind c# public String someImage; public String SomeImage { set { if (someImage != value) { someImage = value; } } get { return someImage; } } InitializeComponent part: if(true) { someImage = "backgroundListViewGren.png"; } else { someImage = "backgroundListViewRed

What's the simplest way to bind a list of checkboxes to a list of checked values

落爺英雄遲暮 提交于 2020-01-01 04:26:07
问题 I have a list of AvailableItems that I want to display as a list of checkboxes, so that users can pick which items to generate, which are then stored in another list called ItemsToGenerate (my lists are actually just lists of strings). Showing all available items with corresponding checkboxes is easy: <ItemsControl ItemsSource="{Binding Path=AvailableItems}"> <ItemsControl.ItemTemplate> <DataTemplate> <CheckBox Content="{Binding}" /> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl

How to bind with dynamic resource and specifying a path

对着背影说爱祢 提交于 2020-01-01 03:07:08
问题 I want to bind to a resource (DynamicResource) and access properties on that resource, but is there a way to do that? (I want to visualize the default values from constructor in the xaml editor in visual studio. Those cannot be seen when referencing an object through DataContext nor through a property added on my Window class...) Not working xaml: (works in composer but not at runtime...) <Window ... > <Window.Resources> <local:MyClass x:Key="myResource" /> </Window.Resources> <StackPanel>

bound service versus started service on Android and how to do both

大兔子大兔子 提交于 2020-01-01 03:03:28
问题 I am asking a vexed question that has been (partially, to my mind) addressed here and here. Let's say like in many examples we want to create a music application, using (say) a single activity and a service. We want the service to persist when the Activity is stopped or destroyed. This kind of lifecycle suggests a started service: A service is "started" when an application component (such as an activity) starts it by calling startService(). Once started, a service can run in the background

SwiftUI: How to iterate over an array of bindable objects?

删除回忆录丶 提交于 2020-01-01 03:02:26
问题 I'm trying to learn SwiftUI, and how bindings work. I have this code that works, that shows a list of projects. When one project is tapped, a binding to that project is passed to the child view: struct ProjectsView: View { @ObjectBinding var state: AppState @State var projectName: String = "" var body: some View { NavigationView { List { ForEach(0..<state.projects.count) { index in NavigationLink(destination: ProjectView(project: self.$state.projects[index])) { Text(self.state.projects[index]

Binding to UserControl DependencyProperty

≯℡__Kan透↙ 提交于 2020-01-01 02:17:08
问题 I have created a UserControl with some DependencyProperties (in the example here only one string property). When I instantiate the Usercontrol, I can set the property of the UserControl and it is shown as expected. When I am trying to replace the static text by Binding, nothing is displayed. My UserControl looks as follows: <User Control x:Class="TestUserControBinding.MyUserControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx

Delay property on Binding from .Net 4.5 in .Net 4.0

纵然是瞬间 提交于 2019-12-31 09:05:22
问题 How can I implement Delay property from .Net 4.5 (described here) on binding in .Net 4.0? I know I cannot inherit from BindingBase as ProvideValue is sealed. I could implement MarkupExtension but it means I now have to rewrite all properties from BindingExtension is there any other way? 回答1: I would create an AttachedProperty that specifies the amount of time to Delay. The AttachedProperty would start (or reset) a timer when the bound value changes, and would manually update the bound source

Delay property on Binding from .Net 4.5 in .Net 4.0

此生再无相见时 提交于 2019-12-31 09:05:11
问题 How can I implement Delay property from .Net 4.5 (described here) on binding in .Net 4.0? I know I cannot inherit from BindingBase as ProvideValue is sealed. I could implement MarkupExtension but it means I now have to rewrite all properties from BindingExtension is there any other way? 回答1: I would create an AttachedProperty that specifies the amount of time to Delay. The AttachedProperty would start (or reset) a timer when the bound value changes, and would manually update the bound source

Custom WinForms data binding with converter not working on nullable type (double?)

笑着哭i 提交于 2019-12-31 06:24:10
问题 In my WinForms application I implemented custom data binding with support for value converters, similar to WPF. The sample has a new binding class that derives from Binding and allows to attach a custom converter: public class CustomBinding : Binding { private readonly IValueConverter _converter; private readonly object _converterParameter; private readonly CultureInfo _converterCulture; public CustomBinding(string propertyName, object dataSource, string dataMember, IValueConverter