wpf

How do I change RichTextBox paragraph spacing?

I am using a RichTextBox in WPF, and am trying to set the default paragraph spacing to 0 (so that there is no paragraph spacing). While I could do this in XAML, I would like to achieve it programmatically if possible. Any ideas? ...

WPF: Check/Uncheck all checkbox for checkboxes located in gridview cell template?

I'm trying to create a check/uncheck all CheckBox for a number of CheckBoxes that are located inside the cell template of a GridViewColumn. I added this column to a GridView (along with other columns), set the GridView to the view property of a ListView, and then databound the ListView to a collection of custom DataObjects. So, each row ...

How can you two-way bind a checkbox to an individual bit of a flags enumeration?

For those who like a good WPF binding challenge: I have a nearly functional example of two-way binding a checkbox to an individual bit of a flags enumeration (thanks Ian Oakes, original MSDN post). The problem though is that the binding behaves as if it is one way (UI to DataContext, not vice versa). So effectively the check box does ...

Can you do "math" within WPF Styles that are data-bound

I have a button control style and I want to change the padding from whatever the data-bound version is to adjust for a glyph that needs a 2 pixel offset. I'll use SimpleButton from SimpleStyles.xaml as an example (... shows where the trigger code was removed for conciseness): <Style x:Key="SimpleButton" TargetType="{x:Type Button}" Bas...

Can you databind to CornerRadius via WPF Styles?

I have a Button style and can't seem to property databind the border's CornerRadius property to the template. This is a dependency property, so it should be data bindable. I wonder if I'm missing the right XAML syntax to use? <Style TargetType="{x:Type Button}" BasedOn="{x:Null}"> <Setter Property="FocusVisualStyle" Value=...

WPF databinding to interface and not actual object - casting possible?

Hi, Say I have an interface like this: public interface ISomeInterface { ... } I also have a couple of classes implementing this interface; public class SomeClass : ISomeInterface { ... } Now I have a WPF ListBox listing items of ISomeInterface, using a custom DataTemplate. The databinding engine will apparently not (that I have ...

How do I move a wpf window into a negitive top value?

If I use dragMove the wpf window will not move to a location where the y value is negative. I can however set the windows top value to a negative value. Is there a simple way to enable dragMove to allow the top of the window to be moved above the displays 0 position? Edit: It seems that this is the default window's handling of moveW...

Best Practice: When to dispatch back to the UI Thread

I have a question on best pactices. When is the best time to dispatch a call back to the UI when using a helper loading method like the two below? Button1 uses the Dispatcher when returned and Button2 allows the helper loading class to encapsulate the call on the Dispatcher. I tend to favor the Button2. private void Button1_Click(obj...

How to use a DateTime formatted GridViewColumn of WPF ListView?

Hi, I have a small WPF apllication, all column templates are ok an they are textboxes but i couldn't find how to bind a DateTime Column (ie. like a DateTimePicker) to GridViewColumn. thank you... ...

Focus on TextBox in DataTemplate

Hi, I have DataTemplate containing TextBox. I'm setting this template to listbox item on a selection. I'm unable to set focus to textbox in the template. I tried to call MyTemplate.FindName, but it ends with Invalid Operation Exception: This operation is valid only on elements that have this template applied. How can I access it? ...

How to display a progress bar on top of a control in WPF

Hello all, In a WPF UserControl, I have to make to call to a WebService. I am making this call on a separate thread but I want to inform the user that the call may take some time. The WebMethod returns me a collection of objects and I bind it to a ListBox in my UC. So far, so good... This part works really well. However, I want to dis...

Where to find the status of the WPF Image Control?

Hello all, One of the nice feature of the Image control is that we can specified an Uri as the ImageSource and the image is automatically downloaded for us. This is great! However, the control doesn't seem to have a property indicating if the image loading is in progress or not. Is there a property telling us the status (Downloading, D...

App crashes on changing tabs that contain ListBoxes with ItemTemplates

I have a WPF TabControl with two TabItems. Each TabItem contains a ListBox with a separate ObservableCollection as its ItemsSource. Each ListBox has a different ItemTemplate. No matter which TabItem I set to be selected at startup, that tab will be displayed fine, but when I click on the other tab the application crashes with an 'Ex...

How to paginate an ObservableCollection?

Hello all, I have a ListBox with way too many items in it and the UI is getting slower and slower (virtualization is on, etc). So I was thinking about displaying only the first 20 items and allow to user to navigate through the result set (i.e. ObservableCollection). Does anybody know if a Pagination mechanism exist for the ObservableC...

How do I handle click events in a data bound menu in WPF

I've got a MenuItem whos ItemsSource is databound to a simple list of strings, its showing correctly, but I'm struggling to see how I can handle click events for them! Here's a simple app that demonstrates it: <Window x:Class="WPFDataBoundMenu.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://sc...

Unit test WPF Bindings

I am trying to unit test my WPF databindings using the test suit provided by Microsoft Team System. I would like to be able to test the bindings without showing the window because most of my tests will be for user controls and not actually on a window. Is this possible or is there a better way to do it? The code below works if I show ...

Can a wpf application be deployed without compiling the xaml?

Is it possible to deploy a WPF windows application in such a way that the xaml files can be manipulated at run-time? If possible, I would imagine this would work similar to an asp.net application that can deploy the .aspx pages as content, which are then compiled just-in-time at run-time. I'd like to allow the simple layout of a screen...

How to ignore spelling in a run in WPF RichTextBox

I'm using the built-in SpellCheck for the WPF RichTextBox and would like to ignore spelling errors for some text runs (validated paths). What is the best way of doing this? ...

Hosting Windows Shell Explorer in my WPF App

Is it possible to embed the Windows Explorer file/folder browser view in a WPF or a WinForms window? I basically want to host the file/folder browser as part of my app window. I don't want to re-implement what the shell provides, especially the shell extensions such as TortoiseSVN. ...

Detect Drag'n'Drop file in WPF?

Is it possible to have a WPF window/element detect the drag'n'dropping of a file from windows explorer in C# .Net 3.5? I've found solutions for WinForms, but none for WPF. ...