binding

XAML: Binding a property in a DataTemplate

限于喜欢 提交于 2019-12-20 13:18:12
问题 I'm fairly new to XAML but enjoying learning it. The thing I'm really struggling with is binding a property to an element in a DataTemplate . I have created a simple WPF example to, (hopefully,) explain my problem. I this example I am trying to bind the Visibility property of a CheckBox in a DataTemplate to a Property in my viewmodel. (Using this scenario purely for learning/demo.) I have a simple DataModel named Item , but is of little relevance in this example. class Item :

WPF - MVVM: ComboBox value after SelectionChanged

房东的猫 提交于 2019-12-20 12:42:48
问题 I am new to C# and MVVM, and I've spent all day trying to get the value of a ComboBox to my ViewModel on SelectionChanged . I have managed to figure it out using either CallMethodAction or InvokeCommandAction with the resources: System.Windows.Interactivity.dll Microsoft.Expression.Interactions.dll My problem is that both these methods return the value of the ComboBox before it has changed. Could anyone explain how to get the value after the change? I have spent hours searching through SO and

Best C# bindings for Qt?

六眼飞鱼酱① 提交于 2019-12-20 12:35:26
问题 I've written a game in C# with SDL.NET and OpenGL. I want to add a menu to it, for which I need Qt. What bindings do you recommend for Qt in C#? Qyoto? (apparently it's still unstable in Windows.) qt4dotnet? other? Requirements: fast should just work and be polished - i.e. no weird problems at every step integration with the buildsystem, uic, resources, etc, should work well In fact I'd appreciate any experiences that you can share about using Qt with C#. Edit: I'm now in the middle of a

CollectionViewSource sorting only the first time it is bound to a source

拥有回忆 提交于 2019-12-20 11:37:05
问题 I'm using a DataGrid bound to a CollectionViewSource ( players ), itself bound to the currently selected item of a ListBox ( levels ), each item containing a collection to be sorted/displayed in the DataGrid: <ListBox Name="lstLevel" DisplayMemberPath="Name" IsSynchronizedWithCurrentItem="True" /> ... <!-- DataGrid source, as a CollectionViewSource to allow for sorting and/or filtering --> <CollectionViewSource x:Key="Players" Source="{Binding ElementName=lstLevel, Path=SelectedItem.Players}"

binding radiobuttons group to a property in WPF

北城余情 提交于 2019-12-20 10:24:58
问题 Let's imagine that I have: <RadioButton GroupName="Group1" IsChecked="{Binding Path=RadioButton1IsChecked}" /> <RadioButton GroupName="Group1" IsChecked="{Binding Path=RadioButton2IsChecked}" /> And then in my data source class I have: public bool RadioButton1IsChecked { get; set; } public bool RadioButton2IsChecked { get; set; } public enum RadioButtons { RadioButton1, RadioButton2, None } public RadioButtons SelectedRadioButton { get { if (this.RadioButtonIsChecked) return RadioButtons

WPF : Define binding's default

落花浮王杯 提交于 2019-12-20 10:24:07
问题 In WPF, I would like to be able to template how my bindings are applied by default. For instance, I want to write : Text="{Binding Path=PedigreeName}" But it would be as if I had typed : Text="{Binding Path=PedigreeName, Mode=TwoWay, UpdateSourceTrigger=LostFocus, NotifyOnValidationError=True, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}" Any idea ? Thanks, Patrick 回答1: In addition to Joe White's good answer, you could also create a class that inherits from Binding and sets the

WPF Datagrid binding custom column headers

别来无恙 提交于 2019-12-20 10:10:48
问题 I am trying to figure out how to bind a WPF DataGrid's column header and main data to a data source using an MVVM pattern. The result I'm looking for would look like this: (source: vallelunga.com) I've successfully styled the headers here, but I'm unsure how to bind the values in the headers. Specifically, the IsChecked property of the check-box, the selected index of the combo box and the value of the text box. I was previously using a simple DataTable to populate the main grid data, but I'm

Knockoutjs computed passing parameters

淺唱寂寞╮ 提交于 2019-12-20 08:56:54
问题 I am wondering if it is possible with knockoutjs to pass arguments when binding. I am binding a list of checkboxes and would like to bind to a single computed observable in my viewmodel. In my viewmodel (based on parameter passed to the read function) I want to return true/false based on certain conditions. var myViewModel=function(){ this.myprop=ko.computed({read: function(){ //would like to receive an argument here to do my logic and return based on argument. } }); }; <input type="checkbox"

let and flet in emacs lisp

笑着哭i 提交于 2019-12-20 08:29:25
问题 I don't know if you would call it the canonical formulation, but to bind a local function I am advised by the GNU manual to use 'flet': (defun adder-with-flet (x) (flet ( (f (x) (+ x 3)) ) (f x)) ) However, by accident I tried (after having played in Scheme for a bit) the following expression, where I bind a lambda expression to a variable using 'let', and it also works if I pass the function to mapcar*: (defun adder-with-let (x) (let ( (f (lambda (x) (+ x 3))) ) (car (mapcar* f (list x)) ))

WPF: how to use 2 converters in 1 binding?

安稳与你 提交于 2019-12-20 08:27:52
问题 I have a control that I want to show/hide, depending on the value of a boolean. I have a NegatedBooleanConverter (switches true to false and vice versa) and I need to run this converter first. I have a BooleanToVisibilityConverter and I need to run this converter after the NegatedBoolConverter. How can I fix this problem? I want to do this in XAML. edit: this is a possible solution. That doesn't seem to work. It first converts the value with the seperate converters and then does something