binding

WPF DataGridTemplateColumn Visibility Binding under MVVM

别来无恙 提交于 2020-01-21 09:03:46
问题 I have a DataGrid bound to an ICollectionView in my ViewModel. The DataGrid is inside a UserControl which is used in a few different data scenarios, some of which require certain DataGrid columns while others don't. I just want to bind the DataGridTemplateColumn's Visibility property to the inner label's Content property so if none of the rows contain a value, it will be hidden. I have a String to Visibility converter set, but can't figure out how to find the inner lable's Content property.

WPF DataGridTemplateColumn Visibility Binding under MVVM

百般思念 提交于 2020-01-21 09:03:25
问题 I have a DataGrid bound to an ICollectionView in my ViewModel. The DataGrid is inside a UserControl which is used in a few different data scenarios, some of which require certain DataGrid columns while others don't. I just want to bind the DataGridTemplateColumn's Visibility property to the inner label's Content property so if none of the rows contain a value, it will be hidden. I have a String to Visibility converter set, but can't figure out how to find the inner lable's Content property.

WP8 - access datacontext of parent

此生再无相见时 提交于 2020-01-21 07:13:25
问题 How can I access the datacontext of the parent element in windows phone 8? AncestorType is not available in WP8. <ItemsControl x:Name="Elements" ItemsSource="{Binding MyList}" Grid.Row="2" Grid.Column="3"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <toolkit:WrapPanel /> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ItemsControl.ItemTemplate> <DataTemplate> <Button Content="e" Width="100" Height="100" Command="{Binding MyCommand" /> </DataTemplate> </ItemsControl.ItemTemplate> <

WPF Force rebind

允我心安 提交于 2020-01-21 02:48:06
问题 I have an object that can't inherit DependencyObject OR use NotifyPropertyChanged, and I've binded it to quite a few controls, so when the properties change, I don't want to go to each control and change it's value on the code, so I'm thinking there must be a way to tell the XAML to "Rebind" all that it's bound to with one or two lines of code, instead of going: label1.Content = myObject.DontNotifyThis; label2.Content = myObject.DontNotifyThisEither; label3.Content = myObject

WPF TreeView bound to ObservableCollection not updating root nodes

梦想与她 提交于 2020-01-21 01:47:05
问题 Sorry - my question is almost identical to this one but since it didn't receive a viable answer, I am hoping that someone else has some fresh ideas. I have a WPF TreeView that is bound to a hierarchy of a single type: public class Entity { public string Title { get; set; } public ObservableCollection<Entity> Children { get; set; } } The Entity class implements INotifyPropertyChanged, but I have omitted this code for clarity. The TreeView is bound to an ObservableCollection<Entity> and each

Binding a TextBox to a ListBox SelectedItem

杀马特。学长 韩版系。学妹 提交于 2020-01-20 08:28:06
问题 I am currently trying to implement a relatively simple data management app. I have a class Member and a BindingList<Member> membersList , as well as a ListBox and some TextBox es. The ListBox is bound to membersList . Now I, ideally, want to bind the TextBox es to ListBox.SelectedItem , so that whatever element the user has selected in the ListBox , when they edit a TextBox the element in membersList is updated. I tried just binding the TextBox es to ListBox.SelectedItem , but this made the

binding to width property in code behind

笑着哭i 提交于 2020-01-20 06:04:05
问题 I have a situation where I need to create View box with one button. The xaml for this is as below: Please observe Width property of viewbox. The Width should be increased/decreased according to a slider bar(moving to right increases it, to left decreases it). As listed below I know how to do it in xaml and it works fine. But my requirement is to be able to create viewbox in code behind and assign it the properties. <WrapPanel x:Name="_wrpImageButtons" Grid.IsSharedSizeScope="True"

Binding only part of the margin property of WPF control

余生颓废 提交于 2020-01-18 21:40:35
问题 I have this: <TabControl Margin="0,24,0,0">...</TabControl> I want to bind only the "Top" part of the TabControl, which intuitively I would do it this way: <TabControl Margin="0,{Binding ElementName=TheMenu, Path=Height},0,0"> ... </TabControl> How do I do it ? 回答1: Have you tried using a converter like this? in VB.Net Public Class MarginConverter Implements IValueConverter Public Function Convert(ByVal value As Object, ByVal targetType As System.Type, ByVal parameter As Object, ByVal culture

Binding only part of the margin property of WPF control

久未见 提交于 2020-01-18 21:40:14
问题 I have this: <TabControl Margin="0,24,0,0">...</TabControl> I want to bind only the "Top" part of the TabControl, which intuitively I would do it this way: <TabControl Margin="0,{Binding ElementName=TheMenu, Path=Height},0,0"> ... </TabControl> How do I do it ? 回答1: Have you tried using a converter like this? in VB.Net Public Class MarginConverter Implements IValueConverter Public Function Convert(ByVal value As Object, ByVal targetType As System.Type, ByVal parameter As Object, ByVal culture

Binding only part of the margin property of WPF control

独自空忆成欢 提交于 2020-01-18 21:38:34
问题 I have this: <TabControl Margin="0,24,0,0">...</TabControl> I want to bind only the "Top" part of the TabControl, which intuitively I would do it this way: <TabControl Margin="0,{Binding ElementName=TheMenu, Path=Height},0,0"> ... </TabControl> How do I do it ? 回答1: Have you tried using a converter like this? in VB.Net Public Class MarginConverter Implements IValueConverter Public Function Convert(ByVal value As Object, ByVal targetType As System.Type, ByVal parameter As Object, ByVal culture