binding

Monotouch binding - “Cannot cast from source type to destination type.”

人盡茶涼 提交于 2020-01-05 06:53:08
问题 I am a newbie on Monotouch. Recently, I am working on a Monotouch binding project that binds a custom iOS framework that developed myself into a .NET framework library. I follow the instructions on Xamarin but currently I am having an issue that cannot be resolved. This is my code. **HEADER FILE IN OBJECTIVE C** *GRG.h* @interface GRG: NSObject {} // Shared instance + (GRG*) sharedG; // Preference class @property (nonatomic, readonly) GRGPreferences *preferences; // Driver version @property

How to Bind Two Lists to Two Columns of Wpf DataGrid?

会有一股神秘感。 提交于 2020-01-05 05:55:34
问题 I want to bind two lists to two columns of a Wpf DataGrid. How is this done in Xaml? Class MainWindow Public Property Column1 As List(Of Integer) = New List(Of Integer) From {1, 2, 3} Public Property Column2 As List(Of Integer) = New List(Of Integer) From {4, 5, 6} End Class 回答1: Zip them : dataGrid1.ItemsSource = Column1 _ .Zip(Column2, _ Function(c1, c2) New With { .Column1 = c1, .Column2 = c2 }) XAML ... <DataGridTextColumn Binding="{Binding Column1}" /> <DataGridTextColumn Binding="

Why Are ICommand Properties Treated Specially by Bindings?

点点圈 提交于 2020-01-04 18:16:30
问题 So far, I had the impression that WPF generally looks at the actual type of an object it gets via a binding or in any other way to determine what templates, styles and representation to use. However, I am now confronted with a situation which makes it seem like WPF (also?) looks at the declared property type for some reason. This is an exemplary view model: using System; using System.Windows.Input; public class SimpleViewModel { private class MyExampleCommand : ICommand { public bool

How to Expose multiple DependencyProperties (with same Name) of nested Controls in a UserControl?

♀尐吖头ヾ 提交于 2020-01-04 13:36:25
问题 I tried to solve almost same problem: "How to Expose a DependencyProperty of a Control nested in a UserControl?" The difference is that I have different (2 or more) nested Controls with of the same type . My goal is to make the nested DependencyProperties bindable. The main Problem I am facing is that Binding don't uses the the Getter and Setter of the CLR-Property but the String of the registererd DependencyProperty . With 2 (or more) nested Controls I am facing a naming conflict. To

binding string format from code-behind?

人盡茶涼 提交于 2020-01-04 12:48:33
问题 Please, can some body tell me how to get my double value formatted like "0.0" from code-behind, like this: Binding b = new Binding(DoubleValue); b.StringFormat = "????"; In xaml it works just like that "0.0"... 回答1: What about this? b.StringFormat = "{0:F1}"; See the documentation of StringFormat and also Standard Numeric Format Strings and Custom Numeric Format Strings. EDIT: Just to make clear how a binding would be created and assigned (to the Text property of an imaginary TextBlock named

DataGrid: Help accessing a control defined in a CellEditingTemplate

主宰稳场 提交于 2020-01-04 12:14:42
问题 I am using the WPF DataGrid with a DataGridTemplateColumn. The DataGridTemplateColumn.CellEditingTemplate contains a ComboBox with IsEditable set to 'true'. In my RowEditEnding event handler, I'd like to read the Text property of that ComboBox - the only problem is that I don't know how to retrieve the ComboBox instance within the event handler in order to get to the Text property. For reference, here's my DataTemplate: <!-- ... --> <my:DataGridTemplateColumn.CellEditingTemplate>

WPF Binding View as Content

落花浮王杯 提交于 2020-01-04 09:23:12
问题 I'm experimenting with some code where I need to mix programmatically created controls with controls defined in XAML. Can someone explain why when I bind to the Elements View property, the property's 'get' is called twice, yet when binding to the Template property it gets called only once (as expected). Example output when binding to View : StringElement StringElement BoolElement BoolElement StringElement StringElement Example output when binding to Template : StringElement BoolElement

How to create a data template dependent on an XML Attribute?

╄→гoц情女王★ 提交于 2020-01-04 09:08:12
问题 I'm working on a WPF interface that reads an XML file and displays the data. The XML file would be something like this: <People> <Person Gender="Male"> <Name>Joe</Name> </Person> <Person Gender="Female"> <Name>Susan</Name> </Person> </People> I need a data template dependent on the Gender attribute of Person. This data template is for list box items. the source of the listbox is People. <DataTemplate DataType="Person[@Gender='Male']"> </DataTemplate> <DataTemplate DataType="Person[@Gender=

Binding a WPF TreeView to multiple Lists

北战南征 提交于 2020-01-04 07:33:10
问题 I'd like to display the following structure in a WPF Treeview: public class Group{ public string Groupname; public IEnumerable<Group> Groups; public Ienumerable<User> Member; } My ViewModel looks like this: public class ViewModel{ public Group RootGroup; } I think the XAML Code should look like this: <TreeView> <TreeView.ItemTemplate> <HierarchicalDataTemplate ItemsSource={Binding ViewModel.RootGroup}> <TextBlock Text={Binding Groupname}/> <HierarchicalDataTemplate ItemsSource={Binding Member

How can I set a binding to a Combox in a UserControl?

做~自己de王妃 提交于 2020-01-04 07:16:19
问题 I have spent several days on this issue and can't seem to get it to work. I have a user control that is saved out to a xaml file with the following code: StringBuilder outstr = new StringBuilder(); XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.OmitXmlDeclaration = true; XamlDesignerSerializationManager dsm = new XamlDesignerSerializationManager(XmlWriter.Create(outstr, settings)); dsm.XamlWriterMode = XamlWriterMode.Expression; System.Windows.Markup