wpf

Windows Forms User Control not painting well in WPF application

So, this is the issue: I have a Windows Forms User Control that I placed in main Window of my WPF application. I override paint method of User Control. It paints ok in "ideal" case. But, after showing the control in main window, I added MessageBox. This is the code snippet: board = new BoggleBoard(Boggle.CurrentGame.Size); board...

Changing ContentTemplate based on ListBox selection

Hi, I have a Listbox and a Border in a StackPanel similar to the following: <StackPanel Orientation="Horizontal"> <ListBox> <ListBoxItem Content="People"/> <ListBoxItem Content="Animals"/> <ListBoxItem Content="Cars"/> </ListBox> <Border Width="200> <ContentPresenter/> ...

DataTrigger doesn't enter to the Converter

this is the xaml: <Window x:Class="WpfApplication4.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:local="clr-namespace:WpfApplication4" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300"> <Grid> <Grid.RowDefinitions> <RowDefinition /> ...

I want the moment when a Key is "Down" in the PreviewKeyDown Event in WPF

Hello, when I jump into the PreviewKeyDown the char righthand to the Caret in my RichTextBox is not moved YET. I would like to say to this event do your stuff move the char to the rightside and THEN let me do MY stuff. How can I do that? private void RTB_PreviewKeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Space) {...

Binding a property on on a great-grandchild to an ancestor

I'm not even sure how to express this, so im very sorry if the title is confusing.. My XAML (simplified) looks like this: <UserControl x:Class="PBA.Application.Client.UserControls.UserControls.FreqReserve.OverView" xmlns:FreqReserve="clr-namespace:PBA.Application.Client.UserControls.UserControls.FreqReserve"> ... <DockPanel> ...

Is hard coded XAML faster than code-behind generated XAML?

I have a WPF usercontrol which contains a number of textboxes and buttons. Currently these textboxes and buttons are all created and loaded dynamically into an ItemsControl through the code behind, whenever an instance of the control is created. The only hard-coded XAML is the declaration of the ItemsControl. This can be a bit sluggish ...

Binding to a Guid on a DataView

Hello, first post here but I'm a frequent visitor =) I have a WPF application with .NET 4.0 and Visual Studio 2010 which uses DataViews (coming from an SQL Server 2008). I have two tables which looks like this Table1 GUID (Primary Key, UniqueIdentifier) Table2_GUID (UniqueIdentifier) Table2 GUID (Primary Key, UniqueIdentifier) ...

I need Wpf tree view like this

ViewModel has 2 field. Name, Childs I need like this 1. When click on the root element, do 2 operation first. expand yourself second. select first child. If child element has childs, repeat 1. otherwise do nothing Only last child (leaf) selectable ...

wpf binding 2 properties of 2 classes

Hello, I have a XAML-object (window-control) having his own-properties in the code-behind (in my case it has a property called 'FirstEditableDate' without any UI-binding). I also have another XAML-object (user-control) with a property (also without UI) and I want to bind the other property to this property. So, if the property of the ...

Is it possible to modify a WPF BitmapSource in memory 'unsafe'ly from another thread

I would like to do some processing of images in a WPF application. However, I would like to modify the pixels of a BitmapSource in memory at runtime. I'm currently managing to do this using 'unsafe' code against an old fashioned System.Drawing.Bitmap and it works a treat (lock a working area, fiddle with the pixels) job done. The approa...

Filtering data at datagrid wpf

I bind a dataset to a datagrid wpf like this DataSet d = Database.getBabies(); babies = d.Tables[0].DefaultView; dataGridBabies.ItemsSource=babies; Which is the best way to filter the data?(without running database query) ...

WPF Custom Window: cannot "unsnap" maximized window with Win7 Aero Snap

I have a WPF application that uses a custom window frame. My problem is that I cannot "unsnap" my maximized window with Aero Snap in Windows 7. Properties of my window: AllowsTransparency is set to true WindowStyle is set to None ResizeMode is set to CanResizeWithGrip. I handle window drag movement like so: private void TitleBarGri...

Using Unity in WPF Custom Controls.

I'm attempting to create a WPF custom control that includes a reference to the unity container that has been created in the BootStrapper - e.g. The reason being that I would like the custom control to be able to resolve the unity container to be able to use some of the services that have been registered to the container. e.g. a user pre...

How do I change the background of my button on mouseover?

I have a WPF application written in C#. I have made a button. I changed the background color. How can I change the bluish color when mouse is over my button? And how to control animation/change time? ...

How to highlight portion of a Rich TextBox WPF control if there are more than 2 spaces?

I have a richtextbox control in my WPF 4.0 application. Now suppose I have a text like "hello how [space][space] r u? [space][space] I am fine" As can be noticed that there are two gaps between how and r as well as between ? and I. When this will happen then the portion will be highlighted with green e.g. how ..r and from ? to I wil...

How can I check the progress of a HttpWebRequest upload?

I wonder how do I check how much of a file has been uploaded/downloaded? I am using HttpWebRequest ...

Application.LoadComponent makes application freeze on shutdown

If I use Application.LoadComponent() to load a UserControl, Page or Window, my application freezes when I try to close it. The app apparently closes, but the process keeps running. Easy to notice when debugging. I've tested it under Windows 7 64bit and Vista 32bit. In both cases I have used VS2008 and .NET 3.5. A repro can be built by...

Correct approach to modifying GUI elements from a worker thread with the Dispatcher?

I've got a bit of an issue here where I want to modify GUI elements from various worker threads. Until today, the method I was using worked, but it was most likely very incorrect. The simplest case involves my plugin's GUI, which does something in a worker thread, and when that method completes its work, it calls my callback. That cal...

multithreaded view models

hello, i have a NavigationWindow that implements a wizard functionality, and a set of Page objects that represent the steps. each Page uses a separate view model. some of these view models spawn worker threads from their constructors. i terminate these threads when the view models are disposed of (they implement IDisposable). further...

WPF Style with no target type?

Hi, How can I have a WPF style that has no target type ( one that can be applied to all objects) ? <Style x:Key="Basic" TargetType="???"> <Setter Property="FontFamily" Value="Tahoma"/> <Setter Property="FontSize" Value="12"/> </Style> I want to base all other styles on this "basic" style. Regards, MadSeb ...