wpf

WPF: How to make controls stretch in a StackPanel?

A Slider and some other controls won't stretch to fill available space when placed in a StackPanel; instead the width is always MinWidth (or about 10 pixels if MinWidth is not set). How do I make it stretch (the equivalent of Anchor.Left|Anchor.Right in WinForms)? Example: <StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal"> ...

Exception when serializing WPF contols

I have an Application (an appointment manager) which lets the user create usercontrols in a stackpanel per button click and the user can enter data into the usercontrols. So far so good. I serialized the stackpanel with XamlWriter.Save(). But then when I try to load it again the next time the application starts with XamlReader.Load() I ...

Restarting a WPF Storyboard

What is the proper way to stop and restart a storyboard from .net code? I'm trying ... myStory.Stop(this); Expecting that a subsequent call to .Begin(this); would restart from the timeline at zero, but instead, the storyboard picks up right where it was stopped. I have tried .Remove(this); and I tried .Seek(TimeSpan.Zero); w...

WPF Font: Why are some characters missing?

I'm writing a WPF app and the font that I am using only has problems running in WPF - it works fine using it in anything else (notepad, wordpad, etc.). The problem with WPF is that it falls back to another font sometimes. By "sometimes" I mean that only characters [a-zA-Z] appear to render correctly - everything else appears to be rend...

How can I overridding a bound property with a DataTrigger

I've got the following XAML used to display detailed information about an item selected in a list view. I want the rectangle to show the standard info color behind the text except when the selected item represents an error message. The code below doesn't work as is and always shows the info color. It works great if I don't specify a Fill...

how to Pass multiple parameters via Command Parameter in WPF??

how to Pass multiple parameters via Command Parameter in WPF?? Do we have to create an object and pass if so can someone help me with an example ...

WPF - Why do ContextMenu items work for ListBox but not ItemsControl?

Items in a list have context menus. The context menu items are bound to routed commands. The context menu items work correctly if the list control is a ListBox, but as soon as I downgrade it to an ItemsControl it no longer works. Specifically the menu items are always greyed out. The CanExecute callback in my CommandBinding is not be...

Saving Word File as a Picture Programmatically

I'd like to save the first page of a Word document as a picture. What methods are there for doing this with C#? ...

Watermark TextBox in WPF

How can I put some text into a textbox which is removed automatically when user types something in it? (In WPF) ...

Deploy XBAP Application?

We have a WPF Application that has a two flavors with a consistent UI etc,one that runs from a Windows OS Desktop and one that is supposed to run as an XBAP application. Currently I am publishing the XBAP application to my localhost machine IIS (Windows XP Pro),Also I have enabled full trust in my scenario as it is needed(Microsoft .NET...

WPF TreeView: Where is the ExpandAll() method

How can I expand all TreeView nodes in WPF? In WinForms there was a ExpandAll() method which does this. ...

FlowDocumentReader scroll bar visibility in Scroll viewing mode

Hi, I need to show FlowDocument with font size slider and search button. FlowDocumentReader in Scroll viewing mode does exactly what I want, except that it always shows vertical scroll bar, whereas I need to show it only when it will be enabled (internally ReaderScrollViewer's VerticalScrollBarVisibility is Visible, but I need Auto). Ho...

[WPF C#]Get UserControl or VisualTree in DataValidation of TextBlock

Hy, I have a validator set on the text property of a textblock. For a correct validation I would need the parent usercontrol of the textblock, but the only things I have in the validator are the value object (a string) and the culture (doesn't help either). Does anyone know a way to get certain usercontrols in a class/a method where I ...

Is there a way to check if a combobox or listboxitem is visible on screen?

If a listbox has many items, is there a way (programatically) to check if an item is visible on screen. For example, the listbox has 100 items, but only first 24 are shown of the screen, is there a way to check if a specific (say list[75]) is currently displayed or one should scroll to see it? ...

WPF Treeview select first child when parent selected

I am using a presentation model to implement navigation in my app with the treeview control. I have the treeviewitem's IsSelected property bound to my view model via two-way binding. When a node that has children is selected, I want the first child of that node to be selected instead of the one that is clicked. It seems like the treeview...

Is there a way to check if WPF is currently executing in design mode or not?

Does anyone know of some global state variable that is available so that I can check if the code is currently executing in design mode (e.g. in Blend or Visual Studio) or not? It would look something like this: //pseudo code: if (Application.Current.ExecutingStatus == ExecutingStatus.DesignMode) { ... } The reason I need this i...

Best Fit a document in Richtextbox.

Using C# How can I show a document in richtextbox without scrollbars, But I need like a bestfit mode? I mean what we are seeing like a preview. ...

Can I use XAML to set a nested property (property of the value of a property) of a control ?

I've got a WPF Control that exposes one of it's children (from it's ControlTemplate) through a read-only property. At the moment it's just a CLR property, but I don't think that makes any difference. I want to be able to set one of the properties on the child control from the XAML where I'm instantiating the main control. (Actually, I w...

Making a WPF TabControl ignore Ctrl+Tab

I'm writing an app that uses the "tabbed browsing" metaphor, with a TabControl the full size of the window, and other stuff inside the tabs. Sometimes those tabs will themselves contain other TabControls. (Tabs inside tabs can be confusing, so I'll re-style the inner TabControl so it doesn't look like a TabControl. I'll probably style i...

Bind Any XML document to WPF TreeView

I would like to bind any XML document to WPF TreeView using TypeConverter. My original solution was to use recursion, but when document is large UI is heavily tied up. Following link talks about TypeConverter but for particular node/element combination: http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/edd843b7-b378-4c2d-926f-c0...