wpf

How do I ensure only the headers are shown for the first item in an ItemsControl in WPF?

I am using MVVM binding an ObservableCollection of children to an ItemsControl. The ItemsControl contains a UserControl used to style the UI for the children. <ItemsControl ItemsSource="{Binding Documents}"> <ItemsControl.ItemTemplate> <DataTemplate> <View:DocumentView Margin="0, 10, 0, 0" /> </Da...

Where should exceptions be caught and handled in a WPF application?

We have exception catching code in most of our event handlers etc, this leads to very complex logic, with flags that are set to say if there has been an exception so as not do the next step etc. At first sight I would move all exception report/logging to the AppDomain.UnhandledException event, however from my experience with WinForms th...

Navigation xBap problem with frames

Hi all I have a problem in navigation in xBap I created two pages (Page1 and Page2) Page1 have one button for navigation to Page 2 <Button Height="23" Width="76" Name="button1" Click="button1_Click">Page2</Button> private void button1_Click(object sender, RoutedEventArgs e) { NavigationService n = NavigationService.GetNav...

Silverlight: Docking of controls

Is it possible to dock Silverlight based controls like Windows Forms control ? For example I want to use a tab control, which I want to use as a control for page navigation ! Unfortunately I don't find a "Dock" property :-( ! ...

WPF ListView DoubleClick OriginalSource problem

Hi ! I attached an EventHandler to the MouseDoubleClick event. <Style TargetType="ListViewItem" BasedOn="{StaticResource MyStyle}"> <EventSetter Event="MouseDoubleClick" Handler="ListViewItem_MouseDoubleClick" /> </Style> private void ListViewItem_MouseDoubleClick(object sender, RoutedEventArgs e) {}...

Loading WPF satellite resources dynamically

Hello! I've read about satellite-assemblies being used in WPF localizations. However, I would like to ask if there is a way to load the satellite-assemblies without following the pre-defined directory structure that depends on the language (ex. If the system language is English, the WPF application looks for the satellite-assembly insid...

Terminate application after unhandled exception

I have a problem in a WPF application. I wrote this code: public partial class App : Application { public App() { AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(MyHandler); } void MyHandler(object sender, UnhandledExceptionEventArgs e) { Exception except...

Transfering set of points to Bezier curve

In my WPF application I'm working on a drawing mechanism to make annotations on top of images. For now I have functionality to draw paths where my drawn path will consist of the collected points from the drawing. More closely I'm adding StylusPoints to an InkPresenter as I collect them through the MouseMoved event. The InkPresenter is se...

WPF Databinding a User Control

I have a user control, A, which wraps a third-party date-picker control, DP. A tells DP's SelectedDate dependency property to two-way bind to A's SelectedDate dependency property, thus effectively exposing the wrapped date-picker's SelectedDate value. I then have a control X which contains an instance of user control A. This tells A's...

WPF: TreeViewItem bound to an ICommand

Hi All, I am busy creating my first MVVM application in WPF. Basically the problem I am having is that I have a TreeView (System.Windows.Controls.TreeView) which I have placed on my WPF Window, I have decide that I will bind to a ReadOnlyCollection of CommandViewModel items, and these items consist of a DisplayString, Tag and a Relay...

ScrollViewer border moves out when HorizontalScrollBarVisibility set to "Auto" or "Visible"

Hello. In XAML I have a ScrollView and a ListView inside. <ScrollViewer Margin="0, 0, 0, 2" HorizontalScrollBarVisibility="Visible"> <ListView BorderBrush="Red" BorderThickness="3" Name="listAnswers"> ... /> So, when I remove the HorizontalScrollBarVisibility tag, my border is unmovable while scrolling, but if I set Horizont...

Learning MVVM for WPF

I am now very comfortable with WPF, but I read some articles about MVP and MVVM that find the default project solution ineffective. Then I realized how ineffective it was and how the MVVM pattern is much better. So I want to really learn this pattern. Can I be directed to some resources like maybe a tutorial or a video or something? ...

Should I run everything in a background thread?

I am designing an application which has the potential to hang while waiting for data from servers (either Database or internet) the problem is that I don't know how best to cope with the multitude of different places things may take time. I am happy to display a 'loading' dialog to the user while access is happening but ideally I don't ...

Keybinding in WPF

I'm new to WPF and in an application i'm building I'd like to show the main menu when the alt key is pressed just like windows explorer in vista and windows 7. I've tried using a keybinding with just the modifier set but that doesn't seem to work. Heres by code so far: <Window.CommandBindings> <CommandBinding Command="{x:Static lo...

How to implement a poor man's DRM solution

I've been tasked with securing video content for an intranet client/server solution. There seams to be a couple of DRM solutions out there, but most of them have various draw backs for us. Cost is a huge factor. Maintaining the "keep honest people honest" philosophy, I was asked if it would be possible to obfuscate the files on the se...

WPF PrintVisual - Selecting XPS in print dialog causing errors

I've spent some time searching for related topics on this, but haven't found any... My problem is that I am getting a few errors when trying to select the Print to Microsoft XPS Document Error. If I choose Print, I'll get the Save dialog. If I select a file and hit OK, it'll properly save my XPS file, but I noticed my WPF window turns...

WPF: How do I position the mouse cursor in code?

I am implementing the system menu (Restore, Move, Size...) on a borderless window and I want the mouse cursor to move to the center of the Window when size or move is selected. Ideally in VB but C# is fine as well. ...

WPF: How to animate a list of components?

Let's say I have a list of visual objects (CustomControls). They could be inside a StackPanel or be items on a ListView, I think the container is part of the answer to this question. Visually, you can think of these objects as items on a queue. Every time I pop an object from the bottom of this queue, I'd like to animate the whole queue...

How can I retrieve the DataTemplate (and specific objects) of an item in an ItemsControl?

I have seen solutions to a very similar issue, yet it doesn't translate to mine. (Namely, this article: http://blogs.msdn.com/wpfsdk/archive/2007/04/16/how-do-i-programmatically-interact-with-template-generated-elements-part-ii.aspx) My ItemsControl is bound to an observable collection, which can have items dynamically added to it. ...

Any disadvantage to using an ElementHost to host a WPF UserControl in a Winform application?

Curious if there are any disadvantages to using an ElementHost to host a WPF UserControl in a Winform application? I ask because in general I feel that it takes to much time for me create a new WPF application with a basic interface that looks decent. Decent in the sense that if I create a new Winforms application and throw some control...