xaml

Making default control template editable in Expression blend

I created my own ContentCOntrol in XAML, e.x.: <ContentControl x:Class="server.ui.DiamondButton"> <ContentControl.Template> <ControlTemplate TargetType="src:DiamondButton"> <...> </ControlTemplate> </ContentControl.Template> </ContentControl> This sets the default template and generally works great....

Adding a UIElementCollection DependencyProperty in Silverlight

I want to add a dependency property to a UserControl that can contain a collection of UIElement objects. You might suggest that I should derive my control from Panel and use the Children property for that, but it is not a suitable solution in my case. I have modified my UserControl like this: public partial class SilverlightControl1 : ...

How to create a data template dependent on an XML Attribute?

I'm working on a WPF interface that reads an XML file and displays the data. The XML file would be something like this: <People> <Person Gender="Male"> <Name>Joe</Name> </Person> <Person Gender="Female"> <Name>Susan</Name> </Person> </People> I need a data template dependent on the Gender attribute of ...

How to override a global style (that doesn't have an x:Key), or alternatively apply a named style to all type-targeted controls?

Hello all! I declared a style that I want to apply to ALL the buttons in the project, the style resides in the ResourceDictionary: <Style TargetType="StackPanel"> <Setter Property="Orientation" Value="Horizontal" /> <Setter Property="VerticalAlignment" Value="Center"/> <Setter Property="HorizontalAlignment" Value="Center"/>...

Padding on StackPanel?

Hello folks! I am trying to set padding of a StackPanel but there ain't such property. I tried StackPanel.Border, but there is no such property either. Any ideas? ...

Escape from DataContext

I have a window that get its data from another class that is passed as DataContext. But I now also want to do data binding within the window. The window looks as follows: <Window x:Class="WpfApplication1.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xa...

Recommend WPF Localization Tool

Can anyone recommend a good WPF localization tool that will do the following: Correctly handle WPF styles Can do binary localization, where no source code is available At least one tool I have tried has failed to generate working satellite assemblies when the source assemblies use WPF styles. ...

WPF, XAML: How to style a ListBoxItem using binding on property of ListBox ItemsSource object?

I have a ListBox which is bound to ObservableCollection of LogMessages. public ObservableCollection<LogMessage> LogMessages { get; set; } public LogMessageData() { this.LogMessages = new ObservableCollection<LogMessage>(); } Each Message has two parameters: public class LogMessage { public string Msg {...

Something missing to display images ? [XAML][C#]

I wrote a file browser in XAML/C#. Files are listed in a listView <ListView Margin="230,0,0,0" Name="listViewContent" ItemsSource="{Binding ContentCollection}"> <ListView.View> <GridView> <GridViewColumn Header="Title" Width="290"> <GridViewColumn.CellTemplate> ...

Force validation on bound controls from XAML?

There is a very similar question already posted. In fact, the result of the answer in that post is exactly what I'm after, but I have no codebehind to place that code in. All of our logic is encapsulated in a ViewModel. Since the ViewModel is not supposed to have direct references to specific visual elements, this code cannot exist there...

WPF Databinding not updating

Hi, I'm trying to change the content of a ContentPresenter to one of my View Model class. I manage to have it shown properly, once I change this content (property) from my model, it doesn't update the ui. The following lines link my view model classes to their respective ui (setting their data context automatically) : <DataTemplate...

How do I customize my type's XAML attribute representation?

Say I have a Date, or a Phone number, or some Class which I don't actually want to store as a string at runtime, but which could have a nice short string serialization for serialization as a XAML attribute: <Person PhoneNumber="+1-123-123-1234"/> How do I make my type serialized in that representation? ...

How to get bind a (WPF or Infragistics) DataGrid to a List<List<string>> or List<string[]>?

I need to bind a collection of strings inside a collection of strings to a DataGrid (Infragistics). However, when I bind it like this: <DataPresenter:XamDataGrid x:Name="xamDataGrid" DataSource="{Binding TheCollection}"> to either this: public List<string[]> TheCollection or this: public List<List<string>> TheCollection I get t...

Using a XAML Image as a WPF Window background

Any suggestions how to go about having a XAML vector image as a Window background? There's plenty of code showing this with jpg's but I'd prefer a vector based image. Having it as a resource would be a bonus too but I'm stumped as to the best approach. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation...

Mixing XAML and code to add controls (WPF)

HI, I have a XAML file where i have defined the UI elements. In my code behind for the window, i add some uielements into one of the controls i have in the xaml file, and when I run it, it does not show up my control that i have added using the c# code. For checking purposes, i tried to remove all controls i had setup via the XAML, in ...

How to set a top margin only in XAML?

I can set margins individually in code but how do I do it in XAML, e.g. how do I do this: PSEUDO-CODE: <StackPanel Margin.Top="{Binding TopMargin}"> ...

XAML 'NOT' operator?

<Button IsEnabled="{Binding (Not IsDisabled)}" /> Is there a way to do it with pure xaml, or I will have to do it via code? PS. I asked the question knowing that I can create a boolean converter like this: <ValueConversion(GetType(Boolean), GetType(Boolean))> Public Class BooleanFlagSwitchConverter : Implements IValueConverter ...

XAML Binding.UpdateSourceTrigger when a Button.Click is fired?

Hi I want to set the UpdateSourceTrigger to an event of a control: <TextBox Text="{Binding Field, UpdateSourceMode=btnOK.Click}"> <Button Name="btnOK"> <Button.Triggers> <Trigger> <!-- Update source --> </Trigger> </Button.Triggers> </Button> I thought about two ways: Set UpdateSourceMode or some...

How to use UpdateSourceTrigger=Explicit in an Items control like ListBox etc.

Hi! I have a ListBox that each of its items has a button, I set all the textboxes in the dataitem that the Binding.UpdateSourceTrigger is Explicit. I added a handler to the button's click, now what? How do I collect the info from the controls? they don't have a key they are dynamic, how do I get their BindingExpressions? <ListBox Ite...

WPF Override XamlWriter

Hi, I need to override the behaviour of XamlWriter when writing out a user control to file. I have control which is just a grid with pictures in, the usercontrol has the grid and 4 properties which set the images. When i use XamlWriter.Save it returns the inner xaml (which includes the grid etc) of the user control, however I just wa...