xaml

WPF: Having HierarchicalDataTemplates in a TreeView

With regards to a question I posted earlier on (WPF: Correctly storing an object in a TreeViewItem) Is it possible to have nested HierarchicalDataTemplates in a TreeView? Take the following example: Code: public class Artist { private readonly ICollection<Album> _children = new ObservableCollection<Album>(); public...

Binary serialization of Silverlight XAML object

I'm working on Silverlight application that needs to display complex 2d vector graphics. It downloads zipped XAML file from the server, parses it (XamlRead) and injects to the layout root on the page. This works fine for fairly small xaml files. The problems is that I need to make it work with much bigger file (lots more content in it)...

Floating child window in WPF

Hi, I want to create floating child window in .NET 3.0 WPF application. What I'm doing is: sideWindow = new SideWindow(this); sideWindow.Left = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width - sideWindow.Width; sideWindow.Top = 125; sideWindow.WindowStartupLocation = WindowStartupLocation.Manual; sideWindow.Owner = this; sid...

WPF: Slider with an event that triggers after a user drags

I am currently making an MP3 player in WPF, and I want to make a slider that will allow the user to seek to a particular position in an MP3 by sliding the slider to the left or right. I have tried using the ValueChanged event but that triggers every time it's value is changed, so if you drag it across, the event will fire multiple times...

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...

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...

In XAML TabControl, how to set the style of the focused tab header?

I can set the background of each TabItem with TabItem.Background, but when that tab is selected it is plain vanilla white. How do I set the style of the tab header that is focused? <TabControl DockPanel.Dock="Top"> <TabControl.Background> <LinearGradientBrush EndPoint="1.115,1.13" StartPoint="0,-0.02"> <Gradien...

WPF - Swapping in and out xaml files to create different screen designs

I am creating an application that uses the MS Ribbon Control. The ribbon has a several tabs. The first tab is labeled "View", the next is labeled "Configure". Under View I show a view of our system, which is laid out in the Window1.xaml file. When I press the Configure tab, I would like the View to go away and be replaced by differ...

How to make WPF resource styles switchable at runtime?

I've got style resources in WPF working so that in my App.xaml I can define whether the customer or administrator layout is used. This works nicely by getting all the style out of the main XAML in a HTML/CSS-like fashion. Now how do I make this dynamic so that I can click on a button in my application and switch the layout between cust...

How to use XAML outside of presentation layer (WPF/Silverlight) ?

XAML is supposed to be "Extensible Application Markup Language" - i.e. a generic, flexible framework for creating application markups. However, most searches for XAML yield either WPF or Silverlight-specific materials. The only exception at this time (that I am aware of) is Oslo framework (M-language & co.) - proving that XAML can be us...

Silverlight : Custom template for a hierarchy treeview

I am using silverlight and want to dynamically generate a hierararchy tree in the following format : Since Silverlight controls are lookless,how can I structure a template that ultimately look like the image? ...

Enabling Scrollbar in WPF

I'm having a problem right now where my WPF application hides anything below the fold when the window is too small vertically. How can I use XAML to get a vertical scrollbar to appear for the entire app so the user can scroll to see the rest of the content? ...

Updating Custom Attached Property in Style Trigger with Setter

Hi All, I was trying out attached properties and style triggers hoping to learn more about it. I wrote a very simple WPF windows app with an attached property: public static readonly DependencyProperty SomethingProperty = DependencyProperty.RegisterAttached( "Something", typeof(int), typeof(Wind...

Use WPF object to 'punch' hole in another?

I've got an ellipse which is just a circle. My problem is I want to cut out a circle-shaped hole from the middle of the bigger circle and nothing seems to work. I've tried opacity masks and those did not work whatsoever. To further complicate things, the big circle has a DropShadowEffect. But because the circle is slightly transparent,...

WPF - Pan & Zoom Image

I want to create a simple image viewer in WPF that will enable the user to: Pan (by mouse dragging the image). Zoom (with a slider). Show overlays (rectangle selection for example). Show original image (with scroll bars if needed). Can you explain how to do it? I didn't find a good sample on the web. Should I use ViewBox? Or ImageB...

WPF - Draw overlay on an image

I have an image that the user can zoom/scroll. I want to draw on a different layer some rectangles/circles (for example: drawing a circle for each person's face that was identified in the picture). The rectangle position is relative to the image. How do I create such an overlay? Thanks. ...

How do I bind to a List<T> using DataContext?

I'm self-learning C#, OOP, and WPF so the potential for stuff ups is staggering. So given that, can someone please explain why after clicking the button in my tiny test example the Name property appears in the TextBox but the ListBox shows nothing? XAML: <Window x:Class="BindingTest.Window1" xmlns="http://schemas.microsoft.com/winfx/2...

WPF: Displaying a Context Menu for a GridView's Items

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

What is the best way to organize WPF styles and ResourceDictionaries in a large project?

I have a large WPF application that uses a large number of styles, brushes, and theming. Managing the large number of styles with multiple developers is becoming difficult. Right now, most of our application-wide styles are in one resource dictionary and the theming brushes are each in their own resource dictionary. The issue is that...

Silverlight Toolkit Treeview: Getting the parent of a selected item

Hi all, I'm using the TreeView component from the Silverlight toolkit and I'm trying to get the parent of a selected node. The TreeView is bound to a series of objects, so directly working with a TreeViewItem appears to be out of the question. <toolkit:TreeView SelectedItemChanged="DoStuff" DisplayMemberPath="Name" ItemsSource="{Bindi...