binding

UWP Using GetBindingExpression with x:Bind

妖精的绣舞 提交于 2021-01-23 06:14:52
问题 I am rewrite my UWP Application from Binding to x:Bind. I have a TextChanged Event on different Textboxes. With Binding I could use GetBindingExpression to update the Model. Is there an equivalent Methode for x:Bind? Or how could I make it with x:Bind? public void TextBox_TextChanged(object sender, TextChangedEventArgs e) { var binding = ((TextBox)sender).GetBindingExpression(TextBox.TextProperty); binding.UpdateSource(); } 回答1: I've tried to do this before without success. I think is not

Why does WPF support binding to properties of an object, but not fields?

浪尽此生 提交于 2021-01-20 09:54:50
问题 I've got a WCF service that passes around status updates via a struct like so: [DataContract] public struct StatusInfo { [DataMember] public int Total; [DataMember] public string Authority; } ... public StatusInfo GetStatus() { ... } I expose a property in a ViewModel like this: public class ServiceViewModel : ViewModel { public StatusInfo CurrentStatus { get{ return _currentStatus; } set { _currentStatus = value; OnPropertyChanged( () => CurrentStatus ); } } } And XAML like so: <TextBox Text

How to create a ContextMenu with items generated from Binding and directly

一世执手 提交于 2021-01-07 01:07:59
问题 Thanks to great @thatguy help I was able to create the menu dynamically, all details and explanation here: How to avoid repeating blocks of XAML in a menu It works perfectly but my problem is that at the end of the list I need to add a separator and a Delete item. This was the code I was using: <ContextMenu ItemsSource="{Binding MyTypes}" ItemContainerStyle="{StaticResource MyMenuItemStyle}"> <Separator HorizontalAlignment="Stretch" Visibility="{Binding MenuSelected.Type, Converter=

How to create a ContextMenu with items generated from Binding and directly

核能气质少年 提交于 2021-01-07 01:07:07
问题 Thanks to great @thatguy help I was able to create the menu dynamically, all details and explanation here: How to avoid repeating blocks of XAML in a menu It works perfectly but my problem is that at the end of the list I need to add a separator and a Delete item. This was the code I was using: <ContextMenu ItemsSource="{Binding MyTypes}" ItemContainerStyle="{StaticResource MyMenuItemStyle}"> <Separator HorizontalAlignment="Stretch" Visibility="{Binding MenuSelected.Type, Converter=

WPF: how to bind ComboBox ItemsSource in code?

自闭症网瘾萝莉.ら 提交于 2021-01-04 07:17:10
问题 I need to convert this following XAML into code-behind: <ComboBox SelectedItem="{Binding Level}" ItemsSource="{Binding Levels}" /> However, this code doesn't compile: new ComboBox() { SelectedItem = new Binding("Level"), ItemsSource = new Binding("Levels") } The error: "Cannot implicitly convert type 'System.Windows.Data.Binding' to 'System.Collections.IEnumerable'. An explicit conversion exists (are you missing a cast?)". How do I cast? 回答1: ComboBox cbo=new ComboBox(); cbo.SetBinding

How to bind input of type time with blazor

守給你的承諾、 提交于 2021-01-02 20:12:57
问题 Hello i have 2 variables of type int that i would like to bind to the min and max values of an input of type time . How can i do this? I do not know what to place in the bind field since there are 2 different variables. Also there is the min and max attributes. <input type="time" min="@model.min" max="@model.max" bind=?/> What should i put in the bind ? Update On a more thoroughly analysis i decided i will need 2 variables of type Timespan and i will bind these to 2 inputs of type time . 回答1:

How to bind input of type time with blazor

 ̄綄美尐妖づ 提交于 2021-01-02 20:12:34
问题 Hello i have 2 variables of type int that i would like to bind to the min and max values of an input of type time . How can i do this? I do not know what to place in the bind field since there are 2 different variables. Also there is the min and max attributes. <input type="time" min="@model.min" max="@model.max" bind=?/> What should i put in the bind ? Update On a more thoroughly analysis i decided i will need 2 variables of type Timespan and i will bind these to 2 inputs of type time . 回答1:

Can I update the value of a WPF binding from the C# code behind?

此生再无相见时 提交于 2020-12-25 02:03:55
问题 I’m learning C# and building a UI that reads and writes integers to an XML config file. The UI uses a variety of custom user controls. I have a 3 radiobutton user control that binds to a single int variable (control returns 0,1,2). The control uses an event to trigger the update. It looks at the 3 isChecked properties to determine the new int value. But I don’t know how to update the original binding value from the code behind. It's once removed so to speak because there are two binds..one in

Can I update the value of a WPF binding from the C# code behind?

99封情书 提交于 2020-12-25 01:59:49
问题 I’m learning C# and building a UI that reads and writes integers to an XML config file. The UI uses a variety of custom user controls. I have a 3 radiobutton user control that binds to a single int variable (control returns 0,1,2). The control uses an event to trigger the update. It looks at the 3 isChecked properties to determine the new int value. But I don’t know how to update the original binding value from the code behind. It's once removed so to speak because there are two binds..one in

Can I update the value of a WPF binding from the C# code behind?

牧云@^-^@ 提交于 2020-12-25 01:57:06
问题 I’m learning C# and building a UI that reads and writes integers to an XML config file. The UI uses a variety of custom user controls. I have a 3 radiobutton user control that binds to a single int variable (control returns 0,1,2). The control uses an event to trigger the update. It looks at the 3 isChecked properties to determine the new int value. But I don’t know how to update the original binding value from the code behind. It's once removed so to speak because there are two binds..one in