wpf

Setting WPF image source in code

I'm trying to set a WPF image's source in code. The image is embedded as a resource in the project. By looking at examples I've come up with the below code. For some reason it doesn't work - the image does not show up. By debugging I can see that the stream contains the image data. So what's wrong? Assembly asm = Assembly.GetExecuting...

WPF: use a ListBox in a template that will be the template of another ListBox

I have a ListBox whose ItemSource is an ObjectDataProvider that is an instance of an ObservableCollection. The ObservableCollection is a collection of ObservableCollections. The ItemTemplate of the ListBox is a DataTemplate that creates a ListBox for each item of the listbox. To illustrate this better I'm trying to recreate a card game i...

Creating a DIP Switch control in WPF

In an effort to teach myself more about WPF, I'm trying to build a simple application. Where I work we have some hardware that has a bank of 8 dip switches used for setting an address from 0 to 255 (as an 8-bit number). It's a simple concept that I would like to build into a WPF windows application that would allow users to see the dip s...

WPF RichTextBox with no width set

I have the following XAML code: <Window x:Class="RichText_Wrapping.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1"> <Grid> <RichTextBox Height="100" Margin="2" Name="richTextBox1"> <FlowDocument> <Paragraph> ...

Starting WPF project. Build own controls or buy?

Hello, I am starting a WPF project, which will be fairly complicated in complexity and will make use of a lot of modern UIs, like outlook bar, grids, tabs, etc... I've looked around in the marketplace and there aren't too many control suites. Some of the available ones are either Beta or CTP. Others don't look too polished. Yet others...

Should I ignore InterfaceMethodsShouldBeCallableByChildTypes for WPF generated code?

When using FxCop 1.36 for a WPF application with a single window that has yet to be modified, I get the InterfaceMethodsShouldBeCallableByChildTypes error with the following details: Target : #System.Windows.Markup.IComponentConnector.Connect(System.Int32,System.Object) (IntrospectionTargetMember) Resolution : "Make 'Ma...

WPF - Searching an XML doc for values using XMLTextReader

Ok another WPF question, well I guess this is just general .NET. I have an xml document retreived from a URL. I want to get multiple values out of the document (weather data, location, some other strings). When I use the XmlTextReader I can call my method to pull the values out. The first time I pass the method to search for the xml no...

OpenSource Apps using WPF :::Learning:::

When I was making my first steps in WinForms, I learned from source code of Paint.NET and few other apps (xacc...) using WinForms. Now I need good-quality code to learn from using WPF :) ...

Hierarchical data binding with nested ListViews in WPF

I have some data that has a detail table. I want the data to be presented in a ListView. I want the detail data to appear as a nested ListView when you select an item in the original list. I can't seem to figure out how to get the data binding to work. Here's what I have so far, (the problem is the {Binding Path=FK_History_HistoryItems}...

Showing Bitmap Images in WPF via C#

Hi guys, What I am trying to do is so simple but I am having a hard time making it work. I saw some posts along the same lines but I still have questions. I have a MenuItem object called mnuA. All I want is set the icon property programatically in C#. I have tried the following a) mnuA.Icon = new BitmapImage{UriSource = new Uri(@"c:\ic...

AdornerDecorator and tab stop issues

Hi, I am using IDataErrorInfo to validate and indicate errors in my text boxes. I am finding I have to tab once for the text box and once for the adornerdecorator. I have an error template: <ControlTemplate x:Key="ErrorTemplate"> <StackPanel KeyboardNavigation.IsTabStop="False" > <Border KeyboardNavigation.IsTabStop="F...

Converting XAML ObjectDataProvider to C#

I would like to create my ObjectDataProvider in my C# code behind rather than my XAML. I was wondering how to change this XAML into equivalent C#. The XAML was generated by Microsoft Expression Blend 2, so the d: namespace can be ignored safely. <ObjectDataProvider x:Key="FooSourceDS" ObjectType="{x:Type myNS:FooSource}" d:IsDataSource...

Can you bind the selected item in a listbox to a separate object in WPF?

If I have two objects, one being the list of items, and the other having a property storing the selected item of the other list, is it possible to update the selected item through binding in WPF? Lets say I have these two data structures: public class MyDataList { public ObservableCollection<Guid> Data { get; set; } } public class...

What is the best approach to binding commands in a ViewModel to elements in the View?

Anyone who has tried to implement RoutedCommands in WPF using M-V-VM has undoubtedly run into issues. Commands (non-UI commands that is) should be implemented in the ViewModel. For instance if I needed to save a CustomerViewModel then I would implement that as a command directly on my CustomerViewModel. However if I wanted to pop up a wi...

WPF Xaml Custom Styling Selected Item Style in a ListBox

I have a list box that scrolls images horizontally. I have the following XAML I used blend to create it. It originally had a x:Key on the Style TaregetType line, MSDN said to remove it, as I was getting errors on that. Now I'm getting this error: Error 3 Operation is not valid while ItemsSource is in use. Access and modify elements w...

How to set WPF's Grid.RowDefinitions via Style

Hi! I'm using a couple of Grids to format multiple GridViewColumn.CellTemplates: <ListView SharedSizeScope="true"> <ListView.View> <GridView> <GridViewColumn> <GridViewColumn.CellTemplate> <DataTemplate> <Grid> <Grid.RowDefinitions> <RowDefinition SharedSizeGroup="...

In Silverlight why are some properties prefixed with x e.g x:name and some are not?

In Silverlight (and I guess WPF) why are the properties x:name x:fieldmodifier x:uid the only ones with the prefix x. I understand the x prefix is used to refer to the XML namespace but there are a number of other properties that do not use a prefix such as width. Identifying a control is such a common task it seems odd to require a pr...

.NET: Replacing ImageMagick with WPF-objects

We've all seen cool WPF demo-applications with rich media. My question is if WPF-objects can replace some basic functionality in ImageMagick. Basic functions like resizing images, cropping and so on. The results from .NET 2.0's System.Graphics-namespace's resizing is just sad (GDI+). Maybe I'm using it wrong, but out of the box it seem...

How to embed Powershell window into another wpf window or windows form?

Hi, Is it possible to embed powershell app into another wpf window or windows formm? Or even a DOS propmpt shell? Malcolm ...

How can I speed up the opening of a WPF window in a VS add-in?

I have a Visual Studio add-in which opens a modal WPF window. My problem is that the first time round, it takes 4 seconds for the window to appear which is a clear disservice to the client. So I'm wondering if there is a way to optimize this away? Is there some kind of nifty code to preload the PresentationFramework (or whatever is slo...