xaml

WPF: Is it possible to add or modify bindings via styles or something similar?

I'm still learning the WPF ropes, so if the following question is trivial or my approach wrong-headed, please do speak up... I'm trying to reduce boilerplate and it sounds like styles are a common way to do so. In particular: I've got a bunch of fairly mundane data-entry fields. The controls for these fields have various properties I...

DynamicResource and Dynamic Items in ContextMenu on XamDataGrid

I would like to dynamically create a set of context menu options based upon some properties. Currently, I am creating a context menu as a DynamicResource with the visibility of the menu options bound to the properties, however, it seems that the DynamicResource is created only once, at runtime. Is this true? What I would like to do ...

Binding a Style DataTrigger to a custom ICommand's status property

I have a custom implementation of WPF's ICommand, that executes its bindings in a BackgroundWorker, so that the UI stays responsive. I would like to display a custom effect while the bindings are being executed. For now, the effect is simplified to setting command source's IsEnabled property to False. Later, our designer will come up wi...

WPF: ListBox click and drag selects other items

Hi, Simple question: 1) I click and hold the mouse on a ListBoxItem in a ListBox. 2) Now I drag the mouse cursor down over the next ListBoxItem in the list It now selects this new item. I would like to disable this. So the user has to click an item to select it. Not just drag over it. I have Single selection turned on. Any ideas are...

Silverlight 4 Setting background color of textbox on focus

I am trying to set the background color of a Textbox to white on focus using a Style. My enabled Textbox has a Linear Gradient background by default: <Setter Property="Background"> <Setter.Value> <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"> <GradientStop Color="#e8e8e8" Offset="0.0" /...

DataTemplate / ContentTemplate - exchange controls

How can i solve the following (simplified) problem? M-V-VM context. I want to show text at the UI. In case the user has the rights to change the text, i want to use a textbox to manipulate the text. In case the user has no rights, i want to use a label to only show the text. My main problem: how to exchange textbox and label and bind Te...

Is there any way to programitically change a Data/ItemTemplate in Silverlight?

So I have a Listbox, which is using an ItemTemplate to display an image. I want to be able to change the size of the displayed image in the ItemTemplate. Through databinding I can change the Width, but the only way I can see how to do this is to add a Property (Say, ImageSize) to the class I am binding to and then change every item in ...

How are DynamicResources built and their use in contextmenus.

Are dynamic resources truly dynamic? If I define a DynamicResource, I realise that an expression is created (where?) that is not translated into a resource until runtime, however, What I do not understans is whether this dynamicresouce, once built, is now "Static" For instance, if I create a context menu via a dynamicresource, are the ...

Best method for Binding ComboBox

I am going to be developing a large project which will include a large number of ComboBoxes. Most of these combo boxes will be bound to a database field which is a related to another daataset/table. For instance. I have the following 2 tables: Company {CompanyID, CompanyName, MainContact} Contacts {ContactID, ContactName} And when t...

WPF - Correct Syntax for Using Coverter with Current Binding

Hi, I have a collection of hex strings that represent colours and I am binding a combobox's ItemsSource to that collection. The combobox items are templated to have a filled rectangle with the relevant colour. I therefore need to use a converter to convert the hex value to a string. Easy enough. However, Blend is telling me that this ...

Can't get the new 2009 XAML primitives working, why?

What I'd like to use: 2009 XAML primitives How it would be nice to use them: <sapv:ExpressionTextBox xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" ExpressionType="x:String" /> What actually happens: "Type reference cannot find the public type named String" The examples I see don't have updated namespaces. I ...

Converter problem with XmlDataProvider

Sorry for this, I've just started programming with wpf. I can't seem to figure out why the following xaml displays "System.Xml.XmlElement" instead of the actual xml node content. This is displayed 5 times in the listbox whenever I run it. Not sure where I'm going wrong... <Window x:Class="TestBinding.Window1" xmlns="http://schema...

WPF ComboBox text inside ListBox

I've got a list of ComboBoxes inside a listbox, like so: <ListBox ItemsSource="{Binding Values}"> <ListBox.ItemTemplate> <DataTemplate> <ComboBox ItemsSource="{...}" IsTextSearchEnabled="True" IsEditable="True"/> </DataTemplate> </ListBox.ItemTemplate> </ListBox> The Valu...

Access to bound data in IMultiValueConverter.ConvertBack() in C#/WPF

I have a problem with a multibinding: <Canvas> <local:SPoint x:Name="sp" Width="10" Height="10"> <Canvas.Left><!-- irrelevant binding here --></Canvas.Left> <Canvas.Top> <MultiBinding Converter="{StaticResource myConverter}" Mode="TwoWay"> <Binding ElementName="cp1" Path="(Canvas.Top)"/> <Binding ElementName="cp1" Path="...

Get Listbox properties from ListBoxItem datatemplate

Is there a way to bind a property of the listboxitem to one of it's owning listbox? I want it in a template so I believe that rules out ElementName. ...

How does the VS XAML designer know what to auto-populate certain values with?

<Button Name="MyButton" Content="Test" FontStyle="Italic" /> In the above XAML definition of a button, the FontStyle property is set to Italic. The designer is somehow able to populate a list for me to choose from when I hit the = sign. How is this achieved? Before you answer, consider that the FontStyle property is, appropriately eno...

XAML Path element - how to make soft corners

Hi I'm trying to figure out how to set Data property of the Path element to get soft corners of this type: Right now I have only sharp corners like this: I tried playing with ellipses, but I can't get what I want. Thanks ...

Multiple Keybinding to a single command

My window has just a listview. This facilitates the users to incremental search the db. Since the design does not have a textbox, i've to globally handle the keys. I think it could be achieved by keybinding. But how can i handle all the keys and associate it to a single command. Also suggest me other methods if any. P.S.: I want this i...

[WPF] Custom TabItem in TabControl

I've created CustomTabItem which inherits from TabItem and i'd like to use it while binding ObservableCollection in TabControl <TabControl ItemsSource="{Binding MyObservableCollection}"/> It should like this in XAML, but i do not know how change default type of the output item created by TabControl while binding. I've tried to creat...

Loading an external image via XAML code in WPF?

I have an image lock.png beside of my WPF exe file in the images folder. Now, I'm gonna load it into the WPF Project as an image, I've used the following XAML code: <Image Stretch="Fill" Source="pack://siteoforigin:,,,/images/lock.png" /> It works, but Expression Blend or Visual Studio doesn't show it when I'm working on the project. ...