xaml

How to make add a fade-in/fade-out animation based on ViewModel property value?

I have a ViewModel which exposes the string property PageToolBarVisible which can be true or false: private string _pageToolBarVisible; public string PageToolBarVisible { get { return _pageToolBarVisible; } set { _pageToolBarVisible = value; OnPropertyChanged("PageToolBarVisible"); } } ...

How to make a XAML animation make the element disappear AFTER it has faded out

Thanks to the answer on this stackoverflow question I was able to get the following animation to work, so that when the value of my ViewModel property PageToolBarVisible causes the toolbar to fade in and out. The problem is: the toolbar opacity fades out, but it the space it took up is still present after it fades out the initial tool...

How can I make a XAML Trigger call a XAML Style?

This style correctly fades my toolbar in or out based on the changing of a ViewModel Property: <Style x:Key="PageToolBarStyle" TargetType="Border"> <Style.Triggers> <DataTrigger Binding="{Binding PageToolBarVisible}" Value="true"> <DataTrigger.EnterActions> <BeginStoryboard> <...

Raise MouseButton.Middle in "Click" evenf for a button

I have a button, and when I click on it, I need it to peform as if I have just clicked the scroll wheel on my mouse. Is this possible? <Button x:Name="centreButton" Click="performScrollButtonClick"/> ...

How to get View element to fade in/out based on value of ViewModel property?

The View and ViewModel listed below show two buttons: when you click Show ToolBar, the toolbar fades in when you click Hide ToolBar, the toolbar fades out However, the following things don't work: when the application is loaded and OnPropertyChanged("PageToolBarVisible") is fired, if the value is false then the Toolbar shows in spi...

WPF : Define binding's default

Hi, In WPF, I would like to be able to template how my bindings are applied by default. For instance, I want to write : Text="{Binding Path=PedigreeName}" But it would be as if I had typed : Text="{Binding Path=PedigreeName, Mode=TwoWay, UpdateSourceTrigger=LostFocus, NotifyOnValidationError=True, ValidatesOnDataErrors=True, Valid...

Inheriting from Application Styles (WPF)

I am trying to inherit application-level styles for a certain Window in my WPF application, but I'm having trouble getting it to inherit rather than simply override the existing styles. In App.xaml (under the App.Resources element) I define a style as such: <Style TargetType="Button"> <Setter Property="Padding" Value="6"/> <Set...

How can I specify resources in an MVVM view model?

Suppose I want to show list of objects where each object should have a name and a suitable image (for example MenuItems with Icons, or buttons with text and image). All examples and programs exposed the image in the viewmodel as a path to a PNG file and then bound the Source of an Image to that. But what if I want to use vector images (...

Vertically aligning Labels and TextBlocks at Top in XAML

How can I vertically align a Label and TextBlock at Top so that their first lines of text line up? <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition /> </Grid.RowDefinitions> <Label Grid.Column=...

Convert HTML to XAML

Is there a way to convert HTML into XAML? I noticed that you can paste HTML into a RichTextBox and you can get the XAML by looking at the FlowDocument. However, this is a hack. Is there a better way? ...

Enabling direct content creation in XAML on a dependancy object

I have a class CollectionOfThings. As its name suggests its a simple collection of instances of the Thing class. Thing class has a public default constructor and two simple public get, set properties ID and DisplayName, both are string. CollectionOfThing also has public default constructor. In XAML I would like to use markup like thi...

How to display a text in XAML which contains double and single quotation marks?

In my XAML file I want to display this text which contains double and single quotation marks: You shouldn't choose "Copy if New". None of these work: <TextBlock Text="You shouldn't choose "Copy if New":"/> <TextBlock Text="You shouldn't choose ""Copy if New"":"/> <TextBlock Text="You shouldn't choose \"Copy if New\":"/> <TextBlock...

WPF : InputBindings on a StackPanel

I want to put a command on a ListBoxItem. The ListBoxItem use a DataTemplate composed of a StackPanel (containing an Image and a TextBlock, both using Binding). I want that the doubleclick on that ListBoxItem fire the command. I have tried this : <DataTemplate> <StackPanel> <StackPanel.Resources> <CommonUI:Comma...

XAML - How to have global inputBindings ?

Hi, I have a WPF application with several windows. I would like to define GLOBAL inputBindings. To define LOCAL inputbindings, i just declare the input in Window.InputBindings or UserControl.InputBindings. To define GLOBALs, I wish i could do the same with the Application class... <Application ....> <Application.InputBindings> ... ...

How to create a repeating background with xaml elements in silverlight?

I want to create an area in my application that looks draggable. Usually, you see this done with a background of small dots or squares, or sometimes lines. I'm using Silverlight and I want to simply create a background that is a set of repeating small rectangles. I honestly cannot figure out how to generate a background with xaml. I'...

Using a XAML file as a vector Image Source

I would like to be able to use vector graphics, preferably defined in XAML, as the Source of an Image control, just like I can currently use a raster image like a PNG. That way I could easily mix and match between bitmap and vector images, like this: <StackPanel> <Image Source="Images/Namespace.png"/> <Image Source="Images/Modul...

How to get WPF xaml content by code on form C#

I design a form in WPF project. The xaml content is automatically generated based on the GUI I design (drag/drop,set position on GUI). How can I read/retreive the xaml content data by code in C# on form? ...

WPF routed events , tunneling and bubbling

What is the thinking/philosophy behind having tunneling before Bubbling and not viceversa . ...

Expression blend does not set width and height on elements

I am working with Blend and Visual Studio to create Surface content. Pretty much every item I place and customize in Blend will look different at runtime or when looked at in Visual Studio. The cause of this seems to be because width/height is not always set in the XAML-file - only margins. If the size of the workspace is different thi...

Code-behind for DataTemplate defined in a ResourceDictionary

I've defined a DataTemplate in a ResourceDictionary. The template need some data (for populating a ListBox). Previously the template was a UserControl and the data was provided by setting the DataContext property. Is there some way of using code-behind for a DataTemplate or is using an ObjectDataProvider to provide the data the only opt...