wpf

WPF Binding Fails. Why?

I have this Markup: <GroupBox BorderThickness="2"> <GroupBox.BorderBrush> <SolidColorBrush x:Name="Border"> <SolidColorBrush.Color> <MultiBinding Converter="{StaticResource ConnectionAndLoggedInToBorderBrush}"> <Binding Path="IsConnected"/> <Binding Path=...

How to create a custom MultiSelector / ItemsControl in WPF / C#

I'm trying to create a diagramming application in C# / WPF. What I going for is somewhat similar to Microsoft Visio although I'm not trying to clone it. I kind of wrote this question as I was coding and just put all the issues I had into it in case someone will find it useful. Maybe I've been thinking too hard but I feel like I could thr...

DesignTime data not showing in Blend when bound against CollectionViewSource

I have a datatemplate for a viewmodel where an itemscontrol is bound against a CollectionViewSource (to enable sorting in xaml). <DataTemplate x:Key="equipmentDataTemplate"> <Viewbox> <Viewbox.Resources> <CollectionViewSource x:Key="viewSource" Source="{Binding Modules}"> <CollectionViewSource.Sor...

XAML Refactoring - How to extract common markup

I have some xaml pasted at the end of this question. It's from a resource file in my project. The HierarchicalDataTemplate and the DataTemplate share exactly the same structure. Is there a way to extract the common parts and reference it in? <HierarchicalDataTemplate DataType="{x:Type local:ChapterViewModel}" ...

What is the correct and culture independent way to handle Key in WPF?

Hi, I'm quite confused about handling of Key http://msdn.microsoft.com/en-us/library/system.windows.input.key.aspx in a KeyEventArgs. For example: I want to handle colon key (made on my Italian keyboard with dot + Shift), so I write some code like this if ( e.Key == Key.OemPeriod && e.KeyboardDevice.Modifiers == ModifierKeys.Shift) { ...

Attached property of type list

I want to create an attached property that can be used with this syntax: <Button> <Image .../> <ui:ToolbarItem.DisplayFilter> <TabItem .../> <TabItem .../> <TabItem .../> </ui:ToolbarItem.DisplayFilter> </Button> This is my attempt at doing so: public class ToolbarItem { /// <summary> /// Identifies the DisplayF...

How do you pronounce WPF?

Hi, I'm not a native English speaker, hence sometimes I'm in doubts how to pronounce an english acronym properly. How do you say WPF (Windows Presentation Foundation)? Thanks. ...

How to insert XAML into RichTextBox?

A XAML text stored in database, how can I show its text in a RichTextBox after reading the XAML by XmlReader? StringReader stringReader = new StringReader(xamlString); XmlReader xmlReader = XmlReader.Create(stringReader); rt.Document = ??? ------UPDATE------------------- here is the xamlString contents: <Section xmlns="http://schema...

Multline Text in a WPF Button

How do I get multi-line text on a WPF Button using only C#? I have seen examples of using <LineBreak/> in XAML, but my buttons are created completely programmatically in C#. The number and labels on the buttons correspond to values in the domain model, so I don't think I can use XAML to specify this. I have tried the naive approach belo...

WPF WebBrowser Troubles

Hello everyone, I have a WPF WebBrowser object in my application in which I am trying to view an isolated YouTube video. Every time the WebBrowser navigates to this YouTube video, I (the user) am presented with a dialog box stating the following: File Download - Security Warning Do You Want to Open or Save this file? Is there any w...

How to inform Views of change from the Model, if the Model can be changed by many Presenters?

I have a project where the Model can be altered from one of many Presenters. How can I ensure that the Views are notified of any changes? The usual notification comes from the code behind (or Presenter if using Caliburn), but if the Model was changed from another source how can I properly inform the View(s) of the change? ...

Why is my ImageBrush scaling a Tiled image?

I have the following ImageBrush declaration that I want to use to draw the background of a window. <ImageBrush x:Key="Fondo" ImageSource="Fondo.png" Viewport="0,0,0.1,0.1" TileMode="Tile"/> If I set it using a StaticResource binding to the Background property of the Window the brush is rendered correctly, bu...

Show items in an itemscontrol in two columns (WPF)

I have an items control that is bound to a collection of objects. The object has two properties (name, value) that i display in a textblock and textbox respectively. The list is quite long and I would like to show it in two columns. So my question is, is there any way I can get an Itemscontrol to show its items in two columns? P.S: The ...

WPF making templates for editing

Hi, Im building a small digital signage system to run on internal machines. I would like to provide the editors (non tech people) with some template to choose the layout from. Something in the line of: It should be easy for me to maintain the templates and to create a new template i.e. just create the XAMl markup. Any ideas on how t...

WPF Visibility based upon global variable value

I have a boolean global variable that is set true if an administrator is logged in and wants to amend the content of the lists and comboboxes. As a result, a button is displayed beside each combo to display a dialog box when clicked. If I was not coding for WPF, I would probably include some sort of code similar to the following in each...

WPF PropertyChange does not cascade - animating one custom class dependencyproperty changes other properties - PropertyChange only fires for first

Hi all! Very simplified, this is my problem: (solution in the bottom) I have a custom class, inheriting Animatable and INotifyPropertyChange, containing one DependencyProperty (which I animate, say from 1 to 10) and one extra property (which I want to use from the XAML with a binding): MyClass : Animatable, INotifyPropertyChanged { ...

Get X Y coordinates of elements within an InkCanvas in WPF

Hi, I have an InkCanvas which has it's children programmically added in through C#. They are not set with InkCanvas.LeftProperty or InkCanvas.TopProperty. I was wondering if it was at all possible to get these default X and Y values of the elements. Currently if I check the InkCanvas.LeftProperty or InkCanvas.TopProperty it would return...

How to work with silverlight 3.0 with visual studio 2008?

How to work with silverlight 3.0 with visual studio 2008? Which version or service packs of visual studio should be installed to work with silverlight? I installed silverlight toolkit july 2009 release but controls are not visible in visual studio 2008 RTM i.e. installed in my PC? ...

How to force WPF to use resource URIs that use assembly strong name? Argh!

O.k, this is really irritating, I had noticed previously that the code generated by WPF for loading XAML resources did not appear to use strong names and therefore may be problematic for scenarios where you need to support side by side versions of WPF assemblies. This has turned out to be the case, and it's now causing me problems - I h...

Relation between length and font-size of a string and width of a textbox.

Hi to all. I've a field in a database, this field has a maximum length, and I want to set a textbox to the appropriate width. I'm creating the textboxes in runtime. How can I calculate the value of width property? For example, if I have a field nvarchar(5) named IDClient, and the font-Size is 13, I want to create a texbox with a width ...