wpf

How to bind inverse boolean properties in WPF?

I am open to suggestions with the title. It really is pretty bad. What I have is an object that has an "IsReadOnly" property. If this property is true, I would like to set the "IsEnabled" property on a Button, ( for example ), to false. I would like to believe that I can do it as easily as IsEnabled="{Binding Path=!IsReadOnly}" but tha...

Serialize an image in XAML using XamlWriter

I'm using XamlWriter to serialize a group of WPF objects. One of these objects is an Image control whose Source is set to a file on disk. When the XamlWriter serializes the objects, it sets the source image to an Uri that points to the file on the filesystem. Is there a way to include that data in the Xaml so that instead of referencin...

Organizing multiple Composite WPF applications to share a single Shell

How can I organize multiple Composite WPF applications so that they share a single Shell project but populate their module catalogs from different App.config files? I am writing a suite of applications using Composite Application Guidance for WPF. Each application's functionality is determined by the availability of different modules, w...

Using Generic Types in Window.Resources

I am trying to use Generic Types in Windows.Resources section in XAML code. To attach the notification for a collection of objects my generic collection inherits from ObservableCollection as shown below: public class PresentationModalCollection<T> : ObservableCollection<T> { public PresentationModalCollection(List<T> list) ...

How can I quickly align the controls in a WPF window ?

I noticed that the WPF designer does a very poor job on aligning the controls, compared to the Windows Forms designer. In the window below, I am unable to align each label, so that its text is on the same line as the text in the text box beside. The first label is correctly aligned, but the WPF designer does not give me any snap lines t...

In a horizontal listbox how do I align items to the top?

In a horizontal listbox how do I align items to the top? I have ran out of ideas of where to stick a VerticalAlignment="Top". <Window.Resources> <DataTemplate DataType="{x:Type l:MyType}"> <Grid VerticalAlignment="Top"> <TextBlock VerticalAlignment="Top" Text="{Binding MyValue}" Background="Yellow"/> <...

WPF ListView with horizontal arrangement of items?

Hello, I want to lay out items in a ListView in a similar manner to the WinForms ListView in List mode. That is, where items are laid out not just vertically but horizontally in the ListView as well. I don't mind if the items are laid out like this: 1 4 7 2 5 8 3 6 9 Or like this: 1 2 3 4 5 6 7 8 9 As long as they are presented bot...

How can I determine if my TextBlock text is being trimmed?

The following textblock wraps and trims as expected. The elipsis "..." is displayed when the text is trimmed. <TextBlock MaxWidth="60" MaxHeight="60" Text="This is some long text which I would like to wrap." TextWrapping="Wrap" TextTrimming="CharacterEllipsis" /> I would like to display a tooltip over the text ...

Invalid ContentPropertyAttribute on property 'Text'

I am having trouble setting my ContentProperty to "Text". The error I am given is: Invalid ContentPropertyAttribute on type 'MyType', property 'Text' not found. The code behind looks like this: [ContentProperty("Text")] public partial class MyType: UserControl { public MyType() { InitializeComponent...

Building an "inner stroke" effect from a Polygon.

I'm drawing a whole bunch of Polygons onto a canvas, most of which share an edge with at least one other Polygon. I'd like to indicate a Polygon is "special" by outlining it, however due to the overlapping edges the Stroke on a Polygon tends to be partially drawn over by another Polygon causing the Stroke to look thinner than it should ...

WPF Treeview Item select Problem

I Have Treeview (shown as above) in my app, I have binded it with collection... now the problem is whenever I expand on Colorodo by default Aspen should get selected, means whenever I expand first item that Node should get selected.. Any Ideas/suggestion Please ...

Get/Set nested property values

I'll try to be more descriptive here. A Few Q's: using: var foo = new Foo() { Bar = new Bar() { Value = "Value" } }; var value = DataBinder.Eval(foo, "Bar.Value"); Or: This one It is possible to retrieve an internal nested property using property path syntax. Is there a way to set/trigger a nested property (a regular property not De...

Restyling just part of a wpf control. Is it possible?

I want to restyle just part of a WPF control. (Specifically, I want to make the scroll buttons on a ScrollBar bigger) Now I can do this no problem. I extracted the default style. Made the required tweaks and included the modified style in my application. The problem is that I have to include the entire control template in the replacem...

Wpf + Winforms WebBrowser security in Vista

I have a simple WPF app that browses to a web cam. Same issue for winforms app. This works great on XP but fails on Vista ? Looks like IE is doing some sand boxing on vista. With vista the request to install the activeX happens every time but not on XP. Any one know why or how to make it work ? Here is the WPF code. <Window x:Class="W...

wpf DoDragDrop IndexOutOfRangeException

I'm trying to implement drag and drop behaviour between a bunch of ListViews. I've found this solution that uses attached properties: http://www.beacosta.com/blog/?p=53 But whenever I try to perform a drag and drop, I get the following error message in the debug log: A first chance exception of type 'System.IndexOutOfRangeException...

Paste contents to TextBox in ANSI Format

How can I make the textbox contents to ANSI format when paste in C#? ...

Comboxbox Selected Value In XAML

hi, How to set the selectedvalue for combobox. For example i have some values from 1-10 and i want to select the 5th value. I tried using SelectedValue and SelectedItem, But its not working for me. Please reply Thanks Sharath ...

Open File Dialog MVVM

Ok I really would like to know how expert MVVM developers handle an openfile dialog in WPF. I don't really want to do this in my ViewModel(where 'Browse' is referenced via a DelegateCommand) void Browse(object param) { //Add code here OpenFileDialog d = new OpenFileDialog(); if (d.ShowDialog() == true)...

WPF TextBox Custom Dictionary Support

Has anyone found a workaround yet for getting custom dictionary support working for the built in spellchecking on WPF TextBoxes/RichTextBoxes? We've been probing the spelling stuff with reflector hoping to find where the dictionary entries are coming from, but it's looking very much like it's going to be a COM object.... I know it's not...

In C#, how can I set DataContext on a View from the ViewModel?

I"m trying to wrap my head around MVVM. I understand a lot of it, but I'm having difficulty grasping one aspect: Setting DataContext. I want to show an view with a particular object. The user doesn't get to decide what is visible, so I need to create the view in code. Then, I want to set the DataContext of the view to an object (for b...