wpf

WPF: ComboBoxes in ListBox and concurrency

I have code like this: <ListBox ItemsSource="{Binding}"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock>Some Other Stuff Here</TextBlock> <ComboBox ItemsSource="{Binding}" /> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox> The problem is,...

How to hunt down WPF binding errors?

We have a very large project. The Visual Studio debug output log contains several repeating WPF binding errors. For example: System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.; Value='NaN' BindingExpression:Path=Width; DataItem='ContentPresenter' (Name=''); target element is 'ContentP...

WPF: Change background on some combobox items

I'm trying to change the background of certain items in a combobox that meet a condition <ComboBox ItemsSource="{Binding Path=Model.Names, Mode=OneWay}" SelectedValue="{Binding Path=SelectedCompanyName}" DisplayMemberPath="Alias" /> The thing is that "Alias" is saved in two different places (in company and in order) and if they dont m...

Let parent handle the child controls event or command WPF?

Hi, I have a user control that has 2 controls A and B within it. Now, A and B have their own logic in their DragDrop event. The parent that has these 2 controls has to handle the DragDrop from these events in its own way. So I have in the parent something like, parent.A.DragDropEvent += new EventHandler () etc... Now, I want to handl...

.NET - Project Won't Build

I have a WPF/ASP.NET project which I haven't worked on for a while (ResourceBlender.NET - http://resourceblender.codeplex.com/). The project contains a DataLayer and a Core layer, these are both used by the WPF application and ASP.NET project in the solution. If the WPF project is set as the startup project and I try to build the applic...

How can I add paging to an ItemsControl?

I'd like to show items in an ItemsControl in 3*4 pages One cool feature is that I can change the ItemsPanel of an ItemsControl: for example: <ItemsControl> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <UniformGrid Column='3' Row ='4'/> ... How can I unable paging though? If the panel is a StackPanel, scrolling/paging is...

WPF + MVVM - Access object/property in UserControl

Hi! I have searched the net for a way to access an object/property within a UserControl. I have a Page object in my view in wich i load a usercontrol: <UserControl:RichTextEditorControl Height="350" /> How do i access an object/property which resides in the viewmodel of my view from my usercontrol? To put my problem in practice: i h...

How To Convert a Bitmap to a Collection of Paths in WPF (in code not XAML)

I have an occupancy grid that has 3 states - Occupied, Free, Unknown. Occupancy grid is a simple 2 dimensional array of states. The grid represents a floor plan where Occupied=Wall, Free=Open Floor, Unknown=what's behind the wall or not mapped. This grid is say 800x800 wide with each cell representing 5cm of the real world. I want to...

WPF, calling method with parameters in XAML's class

I have an ObjectDataProvider in my XAML that references a method in my Window-deriving class. That is, I have NewForm.xaml.cs with class NewForm and the ObjectDataProvider in NewForm.xaml is referencing a method in NewForm. Currently, with the following XAML, I get a stack overflow error because the NewForm constructor keeps getting ca...

WPF + JScript.NET

Hi, I'm trying to compile (by using jsc.exe) javascript code which is going to run WPF window: import System; import System.Windows; import PresentationFramework; import PresentationCore; import WindowsBase; import WpfApp; App app = new App(); app.MainWindow = new Window1(); app.MainWindow.Show(); app.Run(); WpfApp is my dll with A...

Execute a command associated with a MenuItem

I'm using a simple Menu with some MenuItems inside. Each MenuItem has the Command property bound to a RoutedCommand in my ViewModel. When I click a MenuItem the command correctly executes, but navigating the menu with keyboard raise a problem: if I press the Enter key, nothing happens... I must press Tab before and then press Enter, so t...

Is there something like a QueryUnload event in WPF page-based apps?

I'm working on my first WPF app, using VS 2008. When I worked in VB6, there was a form event called QueryUnload, which one could use to determine how an application was shutting down. I'd like to do the same thing in a page-based WPF application, if that's possible. (My app is not an XBAP application, but a page-based app.) I know th...

WPF repeatbutton in scrollbar only triggers IsPressed from the template, not the style

I have a minor issue. We'd like to put as much stylistic items in the styles and outside of the control templates, to make themeing easier. So for the scrollbar's repeatbutton, I can get all of this to work but IsPressed. That only works from the template. So the template is (basically): <ControlTemplate x:Key="ScrollBarButtonCT" ...

FocusBehavior.InitialFocusControl

I am currently having an issue using the FocusBehavior.InitialFocusControl. The focus works fine with the Data Grid that is in the Content of the HCC but the button in the HeaderedContentControl.Header does not lose focus when pressed. When you click anywhere else it will lose focus but it does not follow the GlowFadeIn/GlowFadeOut tha...

Updating WPF control in "real time"

I'm writing an application which will display the current image seen by a camera and it needs to update the shown image in real time, or close to it. Essentially, I have a camera with which I can capture images and I need to capture one every, say, 1 second and display that image to the screen. Currently, my application has an Image co...

access the Window's DataContext from within a DataGrid

I have some problem to access the Window's DataContext from within a DataGrid. The DataGrid is bound to a IBindingList: public IBindingList Items{ get; set; } private void initItems() { //ItemFactory is a Linq2SQL Context, Items is the view of availabe Items this.Items = this.ItemFactory.Items.GetNewBindingList...

WPF Bind a ListView to Oracle Data Source

Here's a part of XAML of the application I'm working on: <ListView Name="lsvCustomerDetails" ItemsSource="{Binding myDataTable}"> <ListView.View> <GridView> <GridViewColumn Header="Script Name" DisplayMemberBinding="{Binding ID}"/> <GridViewColumn Header="Status" DisplayMemberBinding="{Binding status}"/> ...

Binding to Data in an Inherited Control

I'm having an issue with data binding that doesn't seem logical! I have a control that I have inherited from a custom base class: <a:DataPanel x:Class="Sample.Controls.DataPanel2" x:Name="Panel2" xmlns:a="clr-namespace:Sample.Controls"> <Grid> </Grid> </a:DataPanel> DataPanel is a class that I've inher...

How do bring a WPF Window to front?

I have created a single-instance application and want to activate an already opened window if the user starts the app multiple times. This works fine however I have the problem, that if the already opened window is beyond another applications window, I must bring it to front. I have tried window.Focus() and window.Show() but both of the...

Visual Studio 2010 uses Application.xaml; Blend 4 uses App.xaml

Previously all application level resources in a project I am authoring were stored in App.xaml. Then i decided to migrate from VS 2008 to 2010 and that is where the trouble started. After migrating, I tried to do a little testing using a testing window instead of the normal startup window. After changing the startup object, suddenly I...