wpf-binding

Set value to null in WPF binding.

Hello, please take a look at the following line <TextBox Text="{Binding Price}"/> This Price property from above is a Decimal? (Nullable decimal). I want that if user deletes the content of the textbox (i.e. enters empty string, it should automatcally update source with null (Nothing in VB). Any ideas on how I can do it 'Xamly'? ...

WPF - Attach Binding Debugging when Binding is not in a string

Debugging a binding when it is like this IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListBoxItem}}, Mode=TwoWay, Path=IsSelected}" is easy. You add the following: xmlns:diagnostics="clr-namespace:System.Diagnostics;assembly=WindowsBase" IsChecked="{Binding RelativeSource={Relat...

WPF - Setting DataContext for a Trigger's setter

I have a DataTrigger that I recently refactored. It used to have the "DataContext" set to be a ListBoxItem. Now it is a ContentPresenter. Here is the code: <DataTemplate.Triggers> <DataTrigger Value="True"> <DataTrigger.Binding> <MultiBinding Converter="{StaticResource DisableWorkItemConverter}"> ...

Binding doesn't work for navigation properties.

Hi. I am binding WPF with Entity-Framework. The Window.DataContext property is set to a Quote. This Quote has a property Job, that I have to trigger Quote.JobReference.Load it should load from the server. <ContentControl Content="{Binding Job}" ContentTemplate="{StaticResource JobTemplateSummary}"/> As you can see above, I am t...

WPF - Converter hides dependency on a DependencyProperty

I have a TextBlock (acutally a whole bunch of TextBlocks) where I set the Text to "" if a DependencyProperty in my ViewModel is set to Visiblity.Hidden. I do this via a converter as follows: <TextBlock Margin="0,0,5,0"> <TextBlock.Text> <Binding Converter="{StaticResource GetVisibilityOfColumnTitles}" Path="Name" /> ...

Dynamically change the content of of control based on a value

Hi I want to achieve the following behavior: Depending on a value use a different datatemplate: <DataTemplate x:Key="cardTemplate2"> <Border x:Name="container"> ..... </Border> <DataTemplate.Triggers> <DataTrigger Binding="{Binding Show...

How do I databind to children of a child object?

Below is a sample of my object as XML. I had to take out the actual data because of Privacy, but you should get the gist of things. Currently I have binding working pretty well, but I cant get a box to fill with the necessary Granchild information. The list box is working correctly, and its probably a logical issue on my end that I am ju...

WPF ListView Data Binding?

I have a collection of objects that I wish to bind to a ListView control. In some of the objects, the value of a property that will be displayed in a column in the ListView is an empty string (""). I want to replace the empty string ("") with "n/a" automatically using binding. How can I accomplish this? ...

WPF Formatting text in a TextBlock bound to a string

I have a custom control which has a string Description dependancy property as shown below: <CustomControl> <CustomControl.Description> Hello World </CustomControl.Description> </CustomControl> This description is bound in several places in TextBlock's as shown below: <Button> <Button.ToolTip> <TextBlock Te...

WPF Collections and Databinding

I am new to WPF and trying to wrap my head around WPF's framework, what it does and does not do for you. To clarify this, I would like to know what is the difference between this: public List<MyCustomObject> MyCustomObjects { get { return (List<MyCustomObject>)GetValue(MyCustomObjectsProperty); } set { SetValue(MyCustomObjectsP...

WPF - Can't display ObservableCollection in a window

I have an ObservableCollection that I can't seem to get to display in a window. Here is the code: The View Model: public class QueryParamsVM : DependencyObject { public string Query { get; set; } public QueryParamsVM() { Parameters = new ObservableCollection<StringPair>(); } public ObservableCollection<St...

WPF validation question : how to work with validation which involves 2 fields

Hello there, I have 2 textbox on the screen, one is 'from amount' the other 'to amount'. The validation rule is 'from amount' should be less than 'to amount'. Now my question is ,when user enters a pair of amounts in which 'from amount' is grater than 'to amount', how to make BOTH of the text boxes display with red border. And when u...

WPF Binding Crashes Visual Studio

I have a binding that when ever I set it and try to reload the design view, Visual Studio crashes. (This is in design view in the IDE, not at runtime.) I am looking for a work around. Here is the binding: <Button HorizontalAlignment="Right" x:Name="btnPick" Grid.Column="3" Style="{StaticResource roundButton}" Width="15" Heig...

Is it possible to launch another view using XAML only when button is clicked?

I know that Binding in WPF is a really powerful feature, but I don't know if that is possible. My window is composed of a really simple grid: <Grid Height="593" Width="800" > <Grid.RowDefinitions> <RowDefinition Height="109*" /> <RowDefinition Height="484*" /> </Grid.RowDefinitions> <Grid.Background> ...

Unable to set ContentTemplate via DataTrigger.

I want the ContentTemplate to vary according to the value in the DataTrigger. And yes, I considered using a DataTemplateSelector, but now I need a DataTrigger or better said a MultiDataTrigger. Please take a look at the following sampe app, the DataTemplate doesn't change: <Window x:Class="Window1" xmlns="http://schemas.microsoft.co...

Error while setting a Datacontext for a UserControl in WPF

I have usercontrol where I am trying to set the context as below <UserControl.DataContext> <Binding ElementName="dataGrid" Path="MyViewModel"> </Binding> </UserControl.DataContext> Here dataGrid is a child DataGrid control and MyViewModel is my ViewModel class. Currently its giving following error while runtime: Cannot find ...

How do I programmatically bind a ContentControl's content to the DataContext?

Can someone help me translate this to CLR code: <ContentControl Content="{Binding}" /> ...

Wpf ItemTemplate CurrentItem

I have a simple ListBox.ItemTemplate containing a Label and a TextBox bound to a CSLA Bindable List. When I select the textbox the CurrentItem does not change, It only changes if I select the label. I have IsSynchronizedWithCurrentItem='True'. <ListBox x:Name="ItemsDataGrid" ItemsSource="{Binding Source={StaticResource ...

wpf - updated dependency property not firing binding

I have the following dependency property: public bool IterationSelected { get { return (bool)GetValue(IterationSelectedProperty); } set { SetValue(IterationSelectedProperty, value); } } public static readonly DependencyProperty IterationSelectedProperty = DependencyProperty.Register("IterationSelected", typeof(bool), typeof(...

N-N table and WPF databing

I have 3 data tables: User UserID, UserName 1, Bat 2, John etc... Member MemberID, Member 1, Local 2, Zone etc... UserMember UserID,MemberID 1, 1 1, 2 2, 1 etc... On the user input XAML Form in WPF Check list box is bound to Member table. My Question: I want it so that when the user checks member type, the selected values auto...