binding

WPF event binding from View to ViewModel?

隐身守侯 提交于 2019-12-17 10:44:51
问题 Whats the best way to bind a WPF event in the View to the ViewModel? I got a drop event in my View but I want to replace it to the ViewModel due binding. Found several solutions but none of them did what I aspected. View code: <TextBox AllowDrop="True" PreviewDrop="email_Drop" /> 回答1: One way to handle events in MVVM and XAML is to use the Blend Interactivity features. This namespace contains the InvokeCommandAction and the CallMethodAction classes. InvokeCommandAction lets you bind any event

Does the name of parameter have to be model?

亡梦爱人 提交于 2019-12-17 10:03:12
问题 Hit a strange issue where my model is not binding and shows up on the controller as null. I have a form doing a httppost. My breakpoint in the controller is hit and the parameter I expect to be my model is null. Looking at some example code on another page that works, I copied and pasted it and the only difference was the name of the parameter was 'model' instead of message. View @model Site.Models.ContactMessage @{ ViewBag.Title = "Index"; } <h2>Index</h2> @using (Html.BeginForm()) { @Html

What are the differences between using the New keyword and calling CreateObject in Excel VBA?

╄→гoц情女王★ 提交于 2019-12-17 09:53:48
问题 What criteria should I use to decide whether I write VBA code like this: Set xmlDocument = New MSXML2.DOMDocument or like this: Set xmlDocument = CreateObject("MSXML2.DOMDocument") ? 回答1: As long as the variable is not typed as object Dim xmlDocument as MSXML2.DOMDocument Set xmlDocument = CreateObject("MSXML2.DOMDocument") is the same as Dim xmlDocument as MSXML2.DOMDocument Set xmlDocument = New MSXML2.DOMDocument both use early binding. Whereas Dim xmlDocument as Object Set xmlDocument =

Difference between {Binding PropertyName} and {Binding Path=PropertyName}

喜夏-厌秋 提交于 2019-12-17 09:47:48
问题 I've seen both styles used in the same project, and I wonder if there's any semantic difference between them, or if any would be recommended over the other and why. 回答1: There is none. When not specified, the Path property is assigned the value. In other words, Path is the default property of a binding. It's like the "Content" property, which is the default property for many controls. For example <Button>Hello</Button> Is the same as <Button><Button.Content><TextBlock Text="Hello"/></Button>

How to bind SQL variables in PHP?

 ̄綄美尐妖づ 提交于 2019-12-17 07:54:09
问题 I want to bind variables instead of just building SQL strings. Anyway to do this in Php? Either MySQL or PostgreSQL answers would help. Thanks 回答1: There's e.g. PDO. An introduction to pdo and prepared statements (including bound parameters) is located at http://docs.php.net/pdo.prepared-statements 回答2: You should read on the MySQL Improved Extension (MySQLi) at http://php.net/manual/en/book.mysqli.php , and on prepared statements 回答3: For Postgres specifically - pg_query_params (and pg_send

How to bind SQL variables in PHP?

旧街凉风 提交于 2019-12-17 07:54:00
问题 I want to bind variables instead of just building SQL strings. Anyway to do this in Php? Either MySQL or PostgreSQL answers would help. Thanks 回答1: There's e.g. PDO. An introduction to pdo and prepared statements (including bound parameters) is located at http://docs.php.net/pdo.prepared-statements 回答2: You should read on the MySQL Improved Extension (MySQLi) at http://php.net/manual/en/book.mysqli.php , and on prepared statements 回答3: For Postgres specifically - pg_query_params (and pg_send

Use “real” CultureInfo.CurrentCulture in WPF Binding, not CultureInfo from IetfLanguageTag

余生颓废 提交于 2019-12-17 06:39:20
问题 In my case: I have a TextBlock Binding to a property of type DateTime. I want it to be displayed as the Regional settings of the User says. <TextBlock Text="{Binding Date, StringFormat={}{0:d}}" /> I am setting Language property as WPF XAML Bindings and CurrentCulture Display says: this.Language = XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag); But with this line of code it just displays the text as the default format of CultureInfo with IetfLanguageTag of CurrentCulture

How to raise PropertyChanged event without using string name

点点圈 提交于 2019-12-17 06:29:37
问题 It would be good to have ability to raise 'PropertyChanged' event without explicit specifying the name of changed property. I would like to do something like this: public string MyString { get { return _myString; } set { ChangePropertyAndNotify<string>(val=>_myString=val, value); } } private void ChangePropertyAndNotify<T>(Action<T> setter, T value) { setter(value); PropertyChangedEventHandler handler = PropertyChanged; if (handler != null) { handler(this, new PropertyChangedEventArgs(setter

Are “{Binding Path=.}” and “{Binding}” really equal

可紊 提交于 2019-12-17 06:05:12
问题 In my WPF project, I have a ListBox that displays items from a List<string> collection. I wanted to make the text of these items editable, so I wrapped each of them in an ItemTemplate with a TextBox (might not be the best way, but I'm new to WPF). I was having trouble simply binding the TextBoxes' Text property to the value of each item. I finally stumbled upon an example using a single dot or period for its Path property ( {Binding Path=.} ): <ListBox ItemsSource="{Binding ElementName

Binding objects defined in code-behind

霸气de小男生 提交于 2019-12-17 05:41:19
问题 I have some object that is instantiated in code behind, for instance, the XAML is called window.xaml and within the window.xaml.cs protected Dictionary<string, myClass> myDictionary; How can I bind this object to, for example, a list view, using only XAML markups? Update: (This is exactly I have in my test code): <Window x:Class="QuizBee.Host.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="{Binding