xaml

WrapPanel not wrapping when in a StackPanel with Horizontal orientation.

The labels in the example below (WPF/XAML) just parade off the screen, no wrapping occurs. Removing the orientation works, but doesn't provided the needed functionality/look & feel. Any ideas how to make the wrap panel wrap to the current size of the StackPanel? <Window Height="300" Width="600"> <StackPanel Orientation="Horizontal...

WPF: Custom ListBoxItem with DataTrigger

I have a WPF List Box containing CheckBoxes. I would like the text colour of the text box to change to red when the ViewModel notices that the bound value is now updated. I have the below XAML but it is not working. I can see the IsUpdated property being queried but when the value is True the colour is not changing. I'm sure I'm miss...

WPF problems with trigger syntax

I can't get the following to work. The goal is to change the ZIndex of the usercontrol when the mouse is over its content. Using a simple property like "Background" instead of ZIndex does not work either. The compiler complains about "Value 'Grid.IsMouseOver' cannot be assigned to property 'Property'. Object reference not set to an ins...

How do I save RichTextBox content into SQL varbinary (byte array) column?

Hi I want to save content of a RichTextBox to varbinary (= byte array) in XamlPackage format. I need technicial advise on how to it. I actually need to know how to convert between FlowDocument to byte array. Is it even recommended to store it as varbinary, or this is a bad idea? Update Code snippet: ///Load byte[] document = GetD...

Dotted border on ListBoxItem in WPF

Hi How can I make the default border on my ListBoxItems a dotted border? See following way of styling it: <Grid.Resources> <Style TargetType="{x:Type ListBoxItem}"> <Setter Property="Height" Value="30" /> <Setter Property="BorderThickness" Value="0,0,0,1" /> <Setter Property="BorderBrush"...

DataTrigger not firing

I have the following xaml: <DockPanel> <DockPanel> <CheckBox IsChecked="{Binding Path=Test}" /> <CheckBox IsChecked="{Binding Path=Test}" /> </DockPanel> <DockPanel DockPanel.Dock="Left" Width="10" Background="Blue"> <DockPanel.Style> <Style> <Style.Triggers> ...

How to set custom property as XAML value?

I have this library with custom Color properties. I wanna be able to use these properties in XAML like this: <Style TargetType="{x:Type eg:MyWindow}"> <Setter Property="Background"> <Setter.Value> <SolidColorBrush Color="CustomClass.CustomColorProperty"/> </Setter.Value> </Sett...

What exactly does WPF Data Binding's "RelativeSource FindAncestor" do?

I am currently working within a WPF user control (the root element of my XAML file is "UserControl"), which I know is being hosted inside a Window. How can I access a property of the Window using data binding? Does anyone know why simply <Binding RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type Window}}" Path="..." />...

Find a ControlTemplate from code

I have a xaml file with this code: <GridViewColumn x:Name="lvCol3" Header="Quantità" Width="120" > <GridViewColumn.CellTemplate> <DataTemplate> ...

XPath syntax within binding XAML

What is the syntax for using XPath with Binding in XAML? Are there any MSDN pages which describe where to put the braces? Visual Studio doesn't like the following: <TextBlock Text="{Binding XPath=/One/Two[@id='0']/Three/@Four}" /> I want the Text of the TextBlock to be set to the value of the Four attribute. ...

XAML support for local-name() in XPath

I'd like to bind to the element name of a node in my XmlDataProvider. I can't seem to get local-name() to work within my XPath expression. Does XAML support local-name()? <TextBlock Text="{Binding XPath=local-name()}" /> ...

Embedding an XDocument within XAML

How can I embed an XDocument within XAML? I've got the following but Visual Studio won't let me put any XML in the XDocument: <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:xlinq="clr-namespace:System.Xml.Linq;assembly=System.Xml.Linq" ...

Implementing a non-hierarchical Master-Detail pattern in WPF

I'd like to implement the Master-Detail pattern in my WPF application, so that when the user selects an item in a ListView its details are displayed elsewhere. However my data source (some XML) is not structured in a hierarchical manner; rather, each item stores a list of IDs which can be used to identify the details in another section o...

WPF Setting Storyboard target in XAML

I currently have a set of buttons that I would like to set triggers so that each one will perform the same animation. Is there a way in XAML to 'pass' the target to the storyboard so that I don't have to rewrite the storyboard each time for each target? ...

WPF - DataTemplate without a container, items as rows in a Grid?

Is there an equivalent mechanism to the ItemsControl.ItemTemplate that works with a Grid? I have a collection of items and I'd like to present them as rows in a Grid so that I can assign Grid.Column to the individual elements inside the template (as opposed to rows in a list control). Is this possible in WPF using standard controls? ...

Mouseover styles on WPF buttons with mixed content

I have a standard button style applied accross my application that specifies a mouseover style that changes the text content from white to black. To achieve this I have tried modifying the button template, removing the ContentPresenter and replacing it with a TextBlock. However, this means that I can't have mixed content such as: <Butto...

Why does OnPropertyChanged not work in Code Behind?

I'm trying to simplify some code by putting the ViewModel models into the code behind and binding the DataContext as "this", but it seems to work differently, in the following example: Why is it when the button is clicked, the TextBlock bound to "Message" does not change, even though OnPropertyChanged("Message") is called? XAML: <Wind...

Are WPF and Silverlight on a collision course?

It seems like these two technologies, already similar, are on a path to merge into a single technology. There are a lot more WPF-like controls in the Silverlight toolbox, and WPF now has Silverlight's VisaulStateManager. At this point, it's probably fair to say that Silverlight has even surpassed WPF in terms of the number of themes avai...

How to add a Blend Behavior in a Style Setter

I have crated a Blend behavior for Button. How can I set that to all of my Buttons in the app. <Button ...> <i:Interaction.Behaviors> <local:MyBehavior /> </i:Interaction.Behaviors> </Button> ...

Silverlight plugin to Determine Page Height?

Hi there, I am currently working on a silverlight business application, so I have come across a little problem and I am looking for some asssistence. In the application I am developing some pages (in the silverlight) can become quite long, but what I am finding is that the ASPX or Browser is determining the page size and the hence the ...