xbind

why does x:Bind expect a static method to bind to?

混江龙づ霸主 提交于 2021-02-11 12:22:35
问题 I have a UWP MVVM application where I bind, amongst others, the following property to a DataGridComboBoxColumn : public List<ComboBoxValues> ListValues { get; set; } = new List<ComboBoxValues>(); XAML: xmlns:local="using:MyProject.ViewModels" <controls:DataGridComboBoxColumn Header="myHeader" Binding="{Binding theSelectedValue, Mode=TwoWay}" ItemsSource="{x:Bind local:PageVM.ListValues, Mode=OneWay}" DisplayMemberPath="theValueOptions"/> I use dependency injection, using Autofac to generate

Page with type parameter

北战南征 提交于 2021-02-07 19:27:46
问题 I would like to use new feature of UWP -> x:Bind. In order to that, all my pages need to have ViewModel property (as described in tutorials). To avoid code duplicity, I have established base class as follows: public abstract class BasePage<TBaseVM> : Page, where TBaseVM : BaseVM { public TBaseVM VM { get; private set; } protected BasePage() { DataContextChanged += (s, e) => VM = e.NewValue as TBaseVM; } } As you can see this BasePage class contains property called "VM" and property is of type

UWP Using GetBindingExpression with x:Bind

你。 提交于 2021-01-23 06:17:03
问题 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

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

Alternative to ElementName in x:Bind with DataTemplates

此生再无相见时 提交于 2019-12-22 03:59:11
问题 When using traditional {Binding} syntax you could specify element name to point to a specific control on the page, and be able to access its properties. For example if the page is named page you could do: {Binding ElementName=Page, Path=Name} With the {x:Bind} syntax it says With x:Bind, you do not need to use ElementName=xxx as part of the binding expression. With x:Bind, you can use the name of the element as the first part of the path for the binding because named elements become fields

How to change default mode of x:Bind?

ぐ巨炮叔叔 提交于 2019-12-11 00:49:03
问题 I don't know why they decided to set default value for Mode to OneTime But that's not what I want most of the time. It wasted my whole day in debugging. Is there a way to set OneWay value as default for Mode of x:Bind ? <!--This will not listen to future changes. it is OneTime by default--> <TextBlock Text="{x:Bind Name}"/> <!--We have to explicitly define Mode value--> <TextBlock Text="{x:Bind Name, Mode=OneWay}"/> 回答1: starting in Windows 10, version 1607 (Anniversary Update), SDK version