wpf

How do I make a WPF data template fill the entire width of the listbox?

I have a listbox data template in WPF. I want one item to be tight against the left side of the listbox and another item to be tight against the right side, but I can't figure out how to do this. So far I have a grid with three columns, the left and right ones have content and the center is a placeholder with it's width set to "*". Wher...

Using WPF, what is the best method to update the background for a custom button control?

In WPF, we are creating custom controls that inherit from button with completely drawn-from-scratch xaml graphics. We have a border around the entire button xaml and we'd like to use that as the location for updating the background when MouseOver=True in a trigger. What we need to know is how do we update the background of the border i...

Is this a crazy way to handle multi Validation types with IDataError and WPF?

Hi We are using the standard method for our controls to report broken BO rules. This is done via the interface IDataError in our BO’s and in XAML the control is bound to the BO’s property etc. This approach works OK. But we need to show 2 types of visuals in the UI depending on the type (or category if you like) of the invalidation erro...

Any way to make a WPF textblock selectable?

I want to make the text displayed in the Witty, an open source Twitter client, selectable. It is currently displayed using a custom textblock. I need to use a TextBlock because I'm working with the textblock's inlines to display and format the @username and links as hyperlinks. A frequent request is to be able to copy-paste the text. In...

What is your favorite WPF how-to video?

I'm learning WPF, and I'd love to see some good WPF training videos. I would bet there have been some great user group presentations or conference talks that have been recorded, so please submit or vote on your favorite. ...

How to add a Page to Frame using code in WPF

I have a Window where I have put a Frame. I would like to add a Page to the Frame when I click a button that is also on the Window but not in the Frame. There are several buttons in the Window and each click on a button should load a different Page in the Frame. Since I'm a total newbie on this WPF stuff it's quite possible that this ap...

How can I set the text of a WPF Hyperlink via data binding?

In WPF, I want to create a hyperlink that navigates to the details of an object, and I want the text of the hyperlink to be the name of the object. Right now, I have this: <TextBlock><Hyperlink Command="local:MyCommands.ViewDetails" CommandParameter="{Binding}">Object Name</Hyperlink></TextBlock> But I want "Object Name" to be bound t...

Creating a XAML Resource from Code Without a Key

Is there a way to add a resource to a ResourceDictionary from code without giving it a resource key? For instance, I have this resource in XAML: <TreeView.Resources> <HierarchicalDataTemplate DataType="{x:Type xbap:FieldPropertyInfo}" ItemsSource="{Binding Path=Value.Values}"> <TextBlock Text="{Binding Path=Name...

INotifyPropertyChanged property name - hardcode vs reflection?

What is the best way to specify a property name when using INotifyPropertyChanged? Most examples hardcode the property name as an argument on the PropertyChanged Event. I was thinking about using MethodBase.GetCurrentMethod.Name.Substring(4) but am a little uneasy about the reflection overhead. ...

How do I access a MessageBox with white?

I have a simple message box in a WPF application that is launched as below: private void Button_Click(object sender, RoutedEventArgs e) { MessageBox.Show("Howdy", "Howdy"); } I can get white to click my button and launch the message box. UISpy shows it as a child of my window I couldn't work out the method to access it. How do ...

What are some good WPF grid controls?

We use a grid control from Infragistics at work. Are there others? Pay or free? ...

What are the various "Build action" settings in VS.NET project properties and what do they do?

For the most part you just take whatever Visual Studio sets it for you as a default.. I'm referring to the BuildAction Property for each file selected in your solution explorer. There are a number of options and its difficult to know what each one of them will do. ...

Change WPF DataTemplate for ListBox item if selected

I need to change the DataTemplate for items in a ListBox depending on whether the item is selected or not (displaying different/more information when selected). I don't get a GotFocus/LostFocus event on the top-most element in the DataTemplate (a StackPanel) when clicking the ListBox item in question (only through tabbing), and I'm out ...

Any way to un-register a WPF dependency property?

I'm running into an unusual problem in my unit tests. The class I'm testing creates a dependency property dynamically at runtime and the type of that dependency property can vary depending on the circumstances. While writing my unit tests, I need to create the dependency property with different types and that leads to errors because you ...

How do I databind a ColumnDefinition's Width or RowDefinition's Height?

Under the View-Model-ViewModel pattern for WPF, I am trying to databind the Heights and Widths of various definitions for grid controls, so I can store the values the user sets them to after using a GridSplitter. However, the normal pattern doesn't seem to work for these particular properties. Note: I'm posting this as a reference quest...

How to bind from a ContentTemplate to the surrounding custom Control?

I've got the following user control: <TabItem x:Name="Self" x:Class="App.MyTabItem" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:app="clr-namespace:App" > <TabItem.Header> <!-- This works --> <TextBlock Text="{B...

How do you determine if WPF is using Hardware or Software Rendering?

I'm benchmarking a WPF application on various platforms and I need an easy way to determine if WPF is using hardware or software rendering. I seem to recall a call to determine this, but can't lay my hands on it right now. Also, is there an easy, code based way to force one rendering pipeline over the other? ...

Any success rendering HDVideo with WPF MediaElement? Is there a better video player option for WPF?

I'm using a WPF MediaElement to render HD video in an application. When the size of the MediaElement gets over about 300 units square the video stutters and the computer is nearly totally unresponsive. I need to render the video full screen. Has anybody had success rendering fullscreen video using the WPF MediaElement? What were the ...

How do I share a menu definition between a context menu and a regular menu in WPF

I have a defined MenuItem that I would like to share between two different menus on one page. The menu contains functionallity that is the same between both menus and I do not want two copies of it. Is there anyway to define a MenuItem in the Page.Resources and reference it in the ContextMenu XAML below? <Page.Resources> <MenuItem x...

How to improve performance and memory usage with a large number of polygons on a canvas?

The project I'm working on needs to render an ESRI shape file, which can have a large number of polygons/shapes. When I add all these polygons, lines, points, etc to the canvas I'm using, it gets really slow. To draw the shapes on the map, I'm creating a Path object, and setting it's Data property to a StreamGeometry. I originally use...