wpf-binding

WPF: Setting DataContext of a UserControl with Binding not working in XAML

Hi, I'm trying to get my first WPF app working using MVVM, and I've hit a little binding problem. The setup is that I have a view & viewModel which holds User details (the parent), and to try and keep things simple I've put a section of that view into a separate view & viewModel (the child). The child view is defined as a UserControl. ...

Problems with binding to Window Height and Width

I have some problems when I try to bind the height and width of a window to properties in my view model. Here is a small sample app to illustrate the problem. This is the code in app.xaml.xs public partial class App : Application { protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); MainWind...

Bind selected item to a text box

Hi can anyone tell ..how to bind selected item in list box to textbox.. I used ElementName= Path=.. But nothing is being displayed... ...

Binding ListBox to List (Collection) in XAML

Hello, I'm learning WPF, so I'm kind of n00b in this. I saw some examples about how to do what I want to do, but nothing exactly... The question: I want to bind List to ListBox. I want to do it in XAML, w/o coding in code behind. How can I achieve that? Right now I do it that way: <!-- XAML --> <ListBox x:Name="FileList"> <ListB...

WPF DataGrid binding to UserControl

I have a DataGrid with one column using a UserControl via a styled DataGridTemplateColumn. I can't seem to get the UserControl to 'see' the object that is in it's containing DataGridCell though. What kind of bindings can I create on the TextBox in my UserControl so that it can look up and see that object?! My UserControl and TemplateCol...

WPF bind to a static double var

hi, i have these double values: public partial class Window1 : Window { public Window1() { InitializeComponent(); double num1 = 50.0; double num2 = 90.0; double num3 = 120.0; double num4 = 20.0; double num5 = 80.0; } } how do i bi...

How can I make a grid of clickable images from a list of data in WPF?

Hello, I am a seasoned C and Java programmer, but an absolute WPF newbie. I am creating a kiosk application that will display a list of images of products that the user will click to see product details and maybe place an order. I am trying to structure my app with MVVM Foundation because I am used to the benefits of structure and test...

WPF: Turning off animations, data binding temporarly for invisible objects?;)

I have a window that contains a tab control - basically multiple sheets with visualizations on them. The visualtizations are: possible very resource intensive during rendering relying on constant data updates to update their underlying models Obviously only one sheet can be visible every time ;) Anyone knows of a good way to turn of...

Dependency Property Set Priority: CodeBehind vs. XAML

When I initialize a control property from code, the binding to the same property defined on XAML don't work. Why? For Example, I set control properties on startup with this statements: myControl.SetValue(UIElement.VisibilityProperty, DefaultProp.Visibility); myControl.SetValue(UIElement.IsEnabledProperty, DefaultProp.IsEnabled); and ...

Data Binding Error retrival

Hello My scenarion is this 1- i have a Form which is dynamically generated with some XML configuration information. 2- i am attaching Data Binding for a textbox in Text_Loaded event a well as Validation Rules and i am attaching Validation.AddErrorHandler for showing message boxs 3- Data Source for the binding is a DataTable. 4- I a...

Binding WPF ComboBox in XAML - Why is it Empty?

I am trying to learn how to bind my simple database (.sdf) to a combobox. I created a dataset with my tables in it. I then dragged a table from the DataSource onto my control. There are no build warnings/errors, and when it runs, the ComboBox is empty. <UserControl x:Class="OurFamilyFinances.TabItems.TransactionTab" xmlns="http...

WPF: Change the style of a ViewBox depending upon the amount of data

Hi there, I have a WPF app that has a ViewBox to display the items in my collection, diplaying a 2-column grid for my results. What I'd like to do is, depending on the number of items in my collection, change the number of columns. E.g if there are < 10 items in the list, then show them in just 1 column; If there are 10 items in my li...

WPF StringFormat={0:C} showing as dollars

Why does this line of code <TextBlock Text="{Binding Net, StringFormat=c}"/> Output the result as $xx.xx when all my regional settings are set to UK. I expect it to output it as £xx.xx. Any ideas? I have tried different variations of the stringformat including StringFormat={}{0:C} but still get the same result. Thanks for looking. ...

How do I keep my DataService up to date with ObservableCollection?

I have a class called CustomerService which simply reads a collection of customers from a file or creates one and passes it back to the Main Model View where it is turned into an ObservableCollection. What the best practice for making sure the items in the CustomerService and ObservableCollection are in sync. I'm guessing I could hooku...

WPF: Get Property that a control is Bound to in code behind

Hi all, I am trying to find a way to get the Property to which a control is bound (in c#). If I have the following: <dxe:ComboBoxEdit DisplayMember="Name" ItemsSource="{Binding Path=NameOptions, Mode=OneTime}" SelectedItem="{Binding Path=Name, UpdateSourceTrigger=PropertyChanged}" /> I am now trying to get the location to which th...

Using WPF TextSearch.Textpath within combo boxes to autopopulate selection

Hello all I am trying to get the TextSearch.Textpath property to work within a WPF applcication but I am running into a wall on searching a bound field. Basically I have bound to some test data and I want to key the search off of the first property which contains a users ID. Here is the xaml I have so far: <Window.Resources> <DataTe...

XmlDataProvider and XPath bindings don't allow default namespace of XML data?

I am struggling to work out how to use default namespaces with XmlDataProvider and XPath bindings. There's an ugly answer using local-name <Binding XPath="*[local-name()='Name']" /> but that is not acceptable to the client who wants this XAML to be highly maintainable. The fallback is to force them to use non-default namespaces in the ...

Double Loaded event in WPF

I had some difficulties with bindng data to custom controll's value made by someone else so i used "Loaded" event to assign control's value during, but i've noticed that this event is fired up twice. How can i find out what's firing that event? (VS2008) Or mayby any solution would be expected :) ...

Binding DataGridComboBoxColumn to a one to many entity framework relation

I have two tables in the model, one table contains entries related to the other table in a one to many relations, for example: Table User ID Name Table Comments ID UserID Title Text I want to show a datagrid in a WPF window with two columns, one text column with the User name and another column with a combobox showing all...

Having hard time binding array of object from web service call to wpf listbox

Hello guys! i started a WPF application (with vs 2008 sp1) which connects to a web service to get Collection of objects. I can be contactInfo[] or groupInfo[]. here is my main.xaml.cs public main() { InitializeComponent(); //service.addContactCompleted +=new addContactCompletedEventHandler(addContactCompleted); ...