binding

binding and closures groovy

懵懂的女人 提交于 2019-12-21 17:42:14
问题 I don't know how to use binding with closures in Groovy. I wrote a test code and while running it, it said, missing method setBinding on the closure passed as parameter. void testMeasurement() { prepareData(someClosure) } def someClosure = { assertEquals("apple", a) } void prepareData(testCase) { def binding = new Binding() binding.setVariable("a", "apple") testCase.setBinding(binding) testCase.call() } 回答1: This works for me with Groovy 1.7.3: someClosure = { assert "apple" == a } void

Show SelectedIndex in WPF Tabcontrol header template

半城伤御伤魂 提交于 2019-12-21 17:08:36
问题 I have 1...n tabcontrols in my application, with the following XAML setup: <TabControl Name="ordersTabControl" ItemsSource="{Binding CoilItems}"> <TabControl.ItemTemplate> <DataTemplate DataType="models:Coil"> <StackPanel> <TextBlock Text="{Binding CoilCode, StringFormat='Coil: {0}'}" /> <TextBlock Text="{Binding ArticleCode, StringFormat='Auftrag: {0}'}" /> <TextBlock Text="{Binding RestWeight, StringFormat='Restgewicht: {0} kg'}" /> </StackPanel> </DataTemplate> </TabControl.ItemTemplate>

deterministic and asynchronous field validation in WPF

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-21 13:11:09
问题 In my MVVM based application I need to validate fields in a data entry from. If possible, I would like to use the standard WPF validation binding with ErrorTemplates. However I would like the execution of the validation logic to be completely driven/triggered by the ViewModel (push to the View, not pull by the View) for the following reasons: It must work asynchronously because validation logic might take a while to execute. I need to be more deterministic and fine grained when validation

Shallow & Deep Binding - What would this program print?

半城伤御伤魂 提交于 2019-12-21 12:14:59
问题 I'm not sure how to do this... function f1() { var x = 10; function f2(fx) { var x; x = 6; fx(); }; function f3() { print x; }; f2(f3); }; For each of the following two binding methods, what would the program print? A) Shallow Binding B) Deep Binding Thanks for the help! 回答1: Deep/shallow binding makes sense only when a procedure can be passed as an argument to a function. Deep binding binds the environment at the time a procedure is passed as an argument. Shallow binding binds the

Bindings Computed Property in Ember TextField

我的梦境 提交于 2019-12-21 12:07:20
问题 I'm trying to bind my data model to the text field in Ember.js. The model has a field that represents a currency value (e.g., $1,000.50). The user can then change this value. Ember receives the data as a Number (1000.50) -not currency formatted. I bind the view to a computed property that has the nice format. Here is my Handlebars template. {{input classNames="amount" valueBinding="p.amountFmt"}}</td> My model looks like: App.Product = Ember.Object.extend({ amount : 0.00, amountFmt: function

Programmatically change validation rule in WPF TextBox

帅比萌擦擦* 提交于 2019-12-21 09:08:31
问题 I have a text input area defined like this: <TextBox> <TextBox.Text> <Binding Path="MyProperty"> <Binding.ValidationRules> <valid:MyValidator/> </Binding.ValidationRules> </Binding> </TextBox.Text> </TextBox> My problem is that, depending on another setting, what is supposed to be inserted here varies. And thus, the validation behavior of the input data should change. How can I in the code behind change the active validation rule for a certain textbox? 回答1: Use BindingOperations.GetBinding()

Programmatically change validation rule in WPF TextBox

徘徊边缘 提交于 2019-12-21 09:07:56
问题 I have a text input area defined like this: <TextBox> <TextBox.Text> <Binding Path="MyProperty"> <Binding.ValidationRules> <valid:MyValidator/> </Binding.ValidationRules> </Binding> </TextBox.Text> </TextBox> My problem is that, depending on another setting, what is supposed to be inserted here varies. And thus, the validation behavior of the input data should change. How can I in the code behind change the active validation rule for a certain textbox? 回答1: Use BindingOperations.GetBinding()

Popup and Togglebutton interaction in wpf

老子叫甜甜 提交于 2019-12-21 09:07:35
问题 I have a control that contains a Togglebutton and a Popup. When the ToggleButton is clicked on, the popup appears. When the ToggleButton is unchecked, the popup should close. Additionally, clicking away from the popup should cause it to close, and cause the Togglebutton to uncheck. I've set this up by setting the StaysOpen property of the Popup to false, and setting the IsChecked property of the toggle button to be two-way bound to the IsOpen property of the Popup. All is well, apart from one

How to set FallbackValue in binding as path to external image file?

天涯浪子 提交于 2019-12-21 08:54:29
问题 I'm trying to set FallbackValue in case when my converter cannot be call, but I'm not sure how to do that. <Image Source="{Binding FallbackValue="Pictures/Unknown.png", Path=LatestPosition.DeviceFamily, Converter={x:Static conv:ConverterSet.DeviceTypeToImageSourceconverter}}" Name="image1" Stretch="Fill" Margin="5,8" Width="150" Height="150" Grid.RowSpan="4" /> Paths of external images in converter looks like that and when LatestPosition!=null the image is set in proper way. private static

Binding to a method with parameter in XAML using polymorphism in ViewModel

泄露秘密 提交于 2019-12-21 07:37:01
问题 I have a TabControl with six tabs in my ResultView. The ViewModel that sits behind this View can be either a ResultTypeOneViewModel or ResultTypeTwoViewModel, each of which derives from ResultViewModel but you can interchangeably use the result viewer with either result type. The difference is that in ResultTypeOneViewModel, tabs 1 & 3 need to be visible and the rest hidden. In ResultTypeTwoViewModel, tabs 2, 3, 4, 5, 6 need to be visible and tab 1 hidden. I wanted to do this via something