xaml

XPATH equality expression value in XAML Errors (С#, WPF)

MSDN says http://msdn.microsoft.com/en-us/library/ms256086.aspx degree[@from != "Harvard"] - All elements where the from attribute is not equal to "Harvard". but when trying to implement this in my xaml code it causes an error because in XAML syntax all the value elements should be placed in quotes, how can i workaround this? <Co...

Setting a property on the ViewModel from the View in WPF

I have a dependency property on my ViewModel which is the DataContext for my View. The ViewModel has no reference to the View. The property on the ViewModel is going to reference a control on the view, but I need to be able to set this property in XAML. How is this possible? One thought I had was to develop a custom control which ha...

Defining DataContext from controller code

Hello, I wish to define the DataContext of my window from an external class to be able to use DI for my data model. I have read some tutorials about it but I still can't get it to work together. Say we have a simple data model : class Data { public String Value { get; set; } public Data() { Value = "Test"; } ...

Autosize for Text in Control Template

Hey, I am creating a template for a button. I want the text that is placed inside the button to grow and shrink with the size of the button. My style: <Style x:Key="BigRoundButtonWithNumber" TargetType="{x:Type Button}"> <Setter Property="OverridesDefaultStyle" Value="False"/> <Setter Property="Foreground" Value="White" /> ...

How to animate ScaleY when Element becomes visible

I'd like to make a WPF UI Element appear to expand vertically when its Visibility property transitions to "Visible". I don't want to hard-code the Height in the animation since I'd like to apply this animation to any UI Element as a Style. So, I'm trying to use ScaleY but am not having any luck. Here is the XAML for the style and the lis...

How do I put a border around an image in WPF?

I have a StackPanel containing five images and I want to put a black border around each image. The XAML I have at the moment is: <Image Name="imgPic1" Width="100" Height="75" Stretch="Fill" VerticalAlignment="Top" /> I thought I would be just able to put a one-unit margin or padding on the image and set a ...

WPF Set Visibility Through Binding

I have a list of Parent objects that contain Children. Both Parents and Children have a Checked boolean property. These object are bound to an ItemsControl that displays the hierarchy. I also have a "Show checked" checkbox that is one of my application settings that will determine the Visibility of the Items in the ItemsControl. So b...

Tool to convert WPF XAML vector icon to Silverlight?

I found some freeware XAML icons that are perfect for my Silverlight project online (http://www.grafile.com/Product_Page.aspx?id=1.36), but these happen to be using WPF XAML, which is not compatible with Silverlight (at least as of version 4). Can anyone recommend a tool for converting from WPF XAML to Silverlight equivalent? Thanks! ...

How do you set the initial state of a checkbox in WPF (either in XAML or code)?

I have two simple related controls on a form, a delete button and a confirm delete checkbox. The idea is to protect against accidental deletions (don't worry, undo will be added later) but still allow the user to delete without annoying confirmations if they so wish. However, I want the initial state of the checkbox to be set. The XAML...

How do I run some simple C# code for a given keypress?

I have a button on a XAML form that calls the btnName_Click() code in the backing cs file. I also want to assign a keyboard shortcut to run that same code. Basically CTRL<- or something similar. This needs to work regardless of the control I'm currently in (there's a TextBox for example that I want to ensure doesn't capture the event i...

Not specifying control names in WPF... performance effect

If you need to access a WPF control from the code behind, you need to supply a Name attribute to it in XAML. In many cases, you don't need to access controls from the code behind, since a lot of coding logic such as binding is better applied directly inside XAML. My question is: Is there a performance gain from not supplying the name a...

Is there any workaround to apply more then one Effect on one UIElement in WPF?

Hi WPF Lovers, Is there any workaround to apply more then one Effect on one UIElement in WPF? e.g. <Button Content="Blurred (Radius=2)"> <Button.Effect> <BlurEffect Radius="2"></BlurEffect> </Button.Effect> ...

How to use QualifiedDouble values in Silverlight XAML?

Hi, I need to define canvas width and height in centimeters, so basically I have such code snippet: <Canvas x:Name="Template" Height="10cm" Width="10cm" /> and VS2010 designer do not give me any error and shows my canvas correctly, but when I want to execute my application I received XamlParseException exception: Failed to creat...

Silverlight ComboBox: Make Selected item Bold?

Hi all, I would like to be able to make the selected item in a Silverlight ComboBox appear in bold -- what's the best way to go about doing this? Thanks! ...

WPF: Replace the XAML of a page or usercontrol (both is ok) at runtime?

I know that it is possible to parse an XAML - file at runtime and create an UIElement which I can insert into my pages grid, no problem there. But what I really want is to replace the whole XAML of my page or usercontrol, is that possible, too? Reasoning: I want to give the users of my application the opportunity to have the applicati...

Can't able to Run the basic Silverlight application

Hi, When I try to run a simple, basic Silverlight application, I got the following error: Can't find the TestPage.html, Make sure the path or internet address is correct. Here is my XAML code: <UserControl x:Class="HelloWorld.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://s...

content of tabiem

i want to have xaml drawing brush icons in my tabitem, next to the text. how should the icons be switched from outside of the style itself? i know how to do it with images (with Tag) but not sure with drawing brushes. thanks ...

How to populate a DataGrid from XAML? or How to create an ObservableCollection from XAML?

Question I have a DataGrid and would like to populate it with some test data, so I can see it in the designer while working on it. How do I do that? What I already have I've created two classes: ProductList using System.Collections.ObjectModel; namespace Wpf.DataGrid { class ProductList { private ObservableCollectio...

How to rotate transform image inside WPF DataGrid cell?

I am rotating an image inside datagrid using animations based on DataTrigger value. It works fine when vertical scrollbar is not visible, but when records are more and vertical scrollbar is displayed and I scrolls up and down other images also starts rotating, which should rotate bcoz there values doesn't matches with condition. Below is...

Override general Button style

We have a general style in default.xaml, targeting all buttons in our application. Is there a way to override this style, and creating a new button based on the default button? ...