binding

DependencyProperty of type “Binding” is not being updated

流过昼夜 提交于 2020-01-01 12:08:49
问题 I'm having trouble creating a DependencyProperty of type "Binding". Other types work ok, and they resolve successfully if I populate them using a binding. In my scenario I want to grab the raw binding, so that I can use it to bind to properties of child objects, in much the same way that DataGrid does columns - ie for each binding specified in a column, it binds to each of the items in the ItemsSource collection, rather than binding the the DataContext itself. <mg:MultiSelectDataGrid x:Name=

What is the difference between DataTemplate and DataContext in WPF?

强颜欢笑 提交于 2020-01-01 10:51:00
问题 I can set the relationship between View Model and view through following DataContext syntax: <UserControl.DataContext> <view_model:MainMenuModel /> </UserControl.DataContext> And I can also set the relationship between View Model and view through following DataTemplate syntax: <DataTemplate DataType="{x:Type viewModel:UserViewModel}"> <view:UserView /> </DataTemplate> What is the difference between the two? Is the second XAML not setting the data context of a view? 回答1: Your second XAML

INotifyPropertyChanged and Threading

吃可爱长大的小学妹 提交于 2020-01-01 10:05:39
问题 I have a base class implementing INotifyPropertyChanged : protected void OnNotifyChanged(string pName) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(pName)); } } public event PropertyChangedEventHandler PropertyChanged; I have a derived class with a property Latitude like so: private double latitude; public double Latitude { get { return latitude; } set { latitude = value; OnNotifyChanged("Latitude"); } } My derived class also has a method Fly that

WPF databinding - set NotifyOnValidationError to true for all bindings with validation rules

对着背影说爱祢 提交于 2020-01-01 09:23:12
问题 In my WPF application, I want to set NotifyOnValidationError to true (the framework defaults it to false) for all child controls/bindings if they have any ValidationRules attached to the binding. Indeed, it would be nice to specify other binding defaults too - e.g. ValidatesOnDataErrors should also always be true. For example, in the following text box I don't want to have to manually specify the NotifyOnValidationError property. <TextBox> <TextBox.Text> <Binding Path="PostalCode"

DataTrigger to make WPF Button inactive until TextBox has value

不羁岁月 提交于 2020-01-01 09:18:31
问题 I want the Button control's property to be IsEnabled="False" until a value is entered into a TextBox in the Window . Code so far: <Button Content="Click Me" Name="ClickMe" VerticalAlignment="Top" Click="ClickMe_Click"> <Button.Style> <Style> <Style.Triggers> <DataTrigger Binding="{Binding ElementName=textBox, Path=Length}" <!-- or even: Binding="{Binding Path=textBox.Length}" --> Value="0"> <Setter Property="Button.IsEnabled" Value="false" /> </DataTrigger> </Style.Triggers> </Style> </Button

Binding ListPicker.SelectedIndex problem

时光总嘲笑我的痴心妄想 提交于 2020-01-01 09:15:19
问题 I'm trying to do a two way binding of the SelectedIndex attribute of a ListPicker in a Windows Phone 7 UserControl. It raises the following exception when I set the DataContext: SelectedIndex must always be set to a valid value. This is the XAML code <Grid x:Name="LayoutRoot"> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <toolkit:ListPicker Grid.Row="0" x:Name="List1" SelectionChanged="Picker_SelectionChanged" SelectedIndex="

Binding a list in a FlowDocument to List<MyClass>?

♀尐吖头ヾ 提交于 2020-01-01 09:13:13
问题 I have a FlowDocument containing stuff bound to my ViewModel like this: <FlowDocumentReader> <FlowDocument> <Paragraph> <Run Text="{Binding MyTextProperty}"/> </Paragraph> </FlowDocument> </FlowDocumentReader> Now I want to display a List of class using some kind of DataTemplate, but got no idea how to start. Say I got a class like: public MyClass { String Title {get;set;} String FlowText {get;set;} } public List<MyClass> MyList {get;set;} And I'd like to bind this to the FlowDocument List,

Binding to the IsSelected property of the parent ListViewItem

巧了我就是萌 提交于 2020-01-01 08:24:36
问题 I'm attempting to bind the Visibility property of a TextBlock that's held within the ItemTemplate for a ListView to the IsSelected property of the TextBlock's parent ListViewItem. With this markup, the TextBlock is always visible. <ListView x:Name="ItemListView" ItemsSource="{Binding Path=Accounts}" Margin="60,0,0,10" Grid.Row="1" Grid.Column="0"> <ListView.ItemTemplate> <DataTemplate> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="100"> </ColumnDefinition> <ColumnDefinition Width="

Binding to the IsSelected property of the parent ListViewItem

≯℡__Kan透↙ 提交于 2020-01-01 08:23:04
问题 I'm attempting to bind the Visibility property of a TextBlock that's held within the ItemTemplate for a ListView to the IsSelected property of the TextBlock's parent ListViewItem. With this markup, the TextBlock is always visible. <ListView x:Name="ItemListView" ItemsSource="{Binding Path=Accounts}" Margin="60,0,0,10" Grid.Row="1" Grid.Column="0"> <ListView.ItemTemplate> <DataTemplate> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="100"> </ColumnDefinition> <ColumnDefinition Width="

Assembly binding redirect not working

本秂侑毒 提交于 2020-01-01 08:18:17
问题 I am trying to deploy a test web app on Azure, but when I run the Azure emulator on my local machine I get this error from the Azure emulator console attached to my WebRole: System.TypeLoadException: Unable to load the role entry point due to the following exceptions: -- System.IO.FileLoadException: Could not load file or assembly 'System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not