wpf

WPF Using Resource Variables in xaml

Hi, I have a Global string in my App.xaml I want to uses in a UserControl xaml how do I reference it? <Application.Resources> <sys:String x:Key="Assembly">Zpg</sys:String> </Application.Resources> I also have a valiable in the UserControl Resources do I use this in a simila way in the xaml? <UserControl.Resources> <sys:String...

Displaying streaming rich text with WPF

I have a WPF application that connects via a socket to a device and gets streaming text data (approx 1 message per second). This data is then displayed on the UI. The user can create rules like "If the data contains 'abc' highlight the line" or "…make it bold", so plain text output will not do, it needs to be "rich" text. My current s...

Dynamic Application-level resources are not dynamic when hosted in ElementHost

I'm hosting a WPF UserControl in a WinForms container. Now, I want to be able to theme/skin the UserControl. To do this, I've got several resource dictionaries that define the "skins." When my app starts up I create a "new System.Windows.Application()" so that Application.Current exists. To change the theme the old skin is removed an...

Display images in TextBlock (WPF)

Hi, I'm working on a simple chat application. Currently the messages are binded to a custom-styled listbox like this (simplified XAML): <ListBox ItemsSource="{Binding MessageCollection}"> <ListBox.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding Text}"/> </DataTemplate> </ListBox.ItemTemplate> ...

How can I invoke the dialog to set printer options manually?

I'm using WPF and need to let users set some print related options like printer and printer properties (e.g. papertray, landscape/portrait, duplex, etc). I'm aware of the PrintDialog class to get a PrintQueue and PrintTicket object. However I need to create I custom solution and can not show the PrintDialog. I manage to get the availabl...

What is the purpose of ObservableCollection raising a PropertyChange of "Item[]"?

What is the purpose of ObservableCollection raising a PropertyChange of "Item[]"? Is this something I should be doing if I have a class that implements INotifyCollectionChanged? Do WPF controls use this PropertyChange of "Item[]" somehow? ...

MVVM Binding to InkCanvas

I seem to have ran into a road block. We are using MVVM with Prism and have a View that requires an Ink Canvas. I've create a StrokeCollection that is being bound from my ViewModel to the View. I am able to set the collection from my viewmodel but changes are not coming up to the ViewModel while the user draws. Is there a way to make...

WPF ListView: Attaching a double-click (on an item) event

I have the following ListView: <ListView Name="TrackListView"> <ListView.View> <GridView> <GridViewColumn Header="Title" Width="100" HeaderTemplate="{StaticResource BlueHeader}" DisplayMemberBinding="{Binding Name}"/> <GridViewColumn Header="Artist" Width="100" HeaderTemplate="{StaticResource BlueHead...

How to programmatically click a button in WPF?

Since there's no button.PerformClick() in WPF, is there a way to click a wpf button programmatically? ...

Threading problem in WPF

Hi all, I'm getting this Exception System.InvalidOperationException was unhandled by user code Message="The calling thread cannot access this object because a different thread owns it." whenever I run the following code public partial class MainScreen : Window { Timer trm; public MainScreen() ...

What are your strategies for putting XAML into styles?

When I create WPF applications, very quickly my XAML starts to bloat. I then approach the XAML/style issue in a HTML/CSS way, looking for repetitive code and packing it into styles which I put into my Window.Resources section. Is this the way others are doing it or is there some better way now in XAML? It just seems that the two blocks...

ListView DisplayMemberBinding vs. DataTemplate

Can I use DisplayMemberBinding and still be able to define a DataTemplate for the Datatype of that column. As soon as I set the DisplayMemberBinding for a column that column ony can display simple text. But I don't want text :) But if I use Celltemplate all cells of that column use the same DataTemplate. But I don't want the same templat...

Right-align items within wpf expander header

I want to have some text in an expander header left aligned, then some text right aligned. I have found how to expand the header to the width of the container, and thought I could simply add a dockpanel and set the second text block to Dock Right, but it doesn't seem to help. Any solutions? <Expander> <Expander.Header> <DockPanel ...

WPF - fast way of getting the visual tree

I add some controls dynamically in a grid children. I will not know how many and I will not know the exact hierarchy. What I want to do is to access some controls that have a specific type (Button for example) and instantiate some properties. What is the best way to do this? ...

WPF Gui that changes size with window?

Does anybody have a suggestion on how to create a gui that can change size with the size of the window. Similar to how Media Center works. If media center is maximized the fonts etc increase in size. So the gui is always "uniform"? ...

Opening a WPF Window in another Thread from a Windows Forms App

OK, I should start this off by saying I'm not sure this is necessarily the right way to deal with this but... Basically I have created a Window in WPF for displaying notifications in my application (a bit like Outlook New Mail notification). I would like to try and show this Window in it's own thread (it might do some work in the future...

Sharing FlowDocuments between multiple RichTextBoxes

A WPF FlowDocument can only belong to a single RichTextBox. However, we'd like to use a single document which can be manipulated at different points (in space and time) in the UI. It will never happen that there are two RichTextBoxes simultaneously displaying a single document (and can't, because WPF will complain). Using a MemoryStream...

WPF: How to hide GridViewColumn using XAML?

I have the following object in App.xaml <Application.Resources> <ResourceDictionary> <GridView x:Key="myGridView" x:Shared="false"> <GridViewColumn Header="Created" DisplayMemberBinding="{Binding Path=Created}"/> ... more code ... And I use this grid view in multiple places. Example: ...

How can I determine the top/left position of a label in WPF?

I have a WPF label contained in a FlowLayoutPanel and I want to determine the position of the label when clicked with the mouse. I am trying to position a pop-up control where near to the label and just need it's location. ...

Copy a ResourceDictionary to a Dictionary in C#

I have a ResourceDictionary only containing string keys and string values. Now I want to have a Dictionary< string, string > with the same content. How would you do that? Whats the fastest solution in C#? Edit: Fastest in terms of perfomance ;) ...