xaml

Binding to a WPF ToggleButton's IsChecked state

I would like to use a WPF ToggleButton to expand and collapse some controls in my application. How can I use XAML to accomplish this? I'm thinking that I could somehow bind the Visibility attribute of some controls to the ToggleButton's IsChecked state, but I do not know how to do this. Maybe I need to give my ToggleButton a Name, then...

Advantages of UI design in XAML

In WPF i can make my UI using .NET 2.0 style like designer.cs, my question is what are the advantages of using XAML for UI design instead of code. ...

Cannot add ToolTip in style

I'm trying to add a ToolTip to a Grid using a Style (as follows): <ResourceDictionary> <Style x:Key="ToolTipGrid" TargetType="{x:Type Grid}" x:Shared="False"> <Setter Property="ToolTip"> <Setter.Value> <ToolTip> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition /> <ColumnDefinition /> </Grid.Colu...

Intellisense while writing XAML

Using VS 2008, or Blend 3, is there any way I can get intellisense for the available properties when creating styles in XAML? I thought I heard there was a third-party freebie that did this. In the snippet below, I want intellisense for the properties like FontSize, Margin, Width, etc. <Style x:Key="MyTextBoxStyle" TargetType="TextBox"...

Bug or User error? Unable to set TextBlock's VerticalAlignment property to Center

Hmmm. . . I'm losing my mind. . . or am I? I'm creating a WPF app for some basic data entry. I'm using textblocks to label the textboxes but ran into a snag. Why can't I vertically center the textblocks? I can't change the vertical alignment at all. Regardless of what I value I set on the property, the textblocks remain at the top. I wa...

Silverlight data binding in the code behind.

I am doing something like this in a Silverlight 3 datagrid: for (int x = 0; x < ThisForecast.Periods.Count; x++) { var TextColumn = new DataGridTextColumn(); TextColumn.Header = ThisForecast.Periods[x].Name; TextColumn.Binding = new Binding(String.Format("Periods[{0}].Quantity", x)); TextColumn.Binding.Mode = BindingMode.Two...

How to add a focus style to an editable ComboBox in WPF

I've been looking at the following example on how to style the combo box, but I haven't been able to create a focus effect when going into a editable combo box. Whenever the combo box receives focus, it should go into edit mode and the component should have a focus style. The basic problem is that whenever I go into the edit mode, it's...

How do I fix this? TwoWay databinding not working.

I'm trying to wire up a slider and textbox such that the textbox controls the slider position and the slider position is reflected in the textbox. This is a basic two-way element-to-element binding. What I have - The slider position displays in the text box. Adjusting the slider is reflected by an updated value in the textbox. This work...

How to create a WPF validation rule to ensure two text fields have the same value?

How would I create a validation rule to ensure Value2 has the same value as Value1? If a validation rule is not the best method then what would be better? I could have the TextChanged event handle this, but I'm wondering if there is something more elegant. <TextBox Name="Value1TextBox"> <TextBox.Text> <BindingPath Path="Valu...

Select Individual XML Bound Items in TreeView

I am trying to learn to bind the following simple XML file to a WPF TreeView: <?xml version="1.0" encoding="utf-8" ?> <Profiles> <Customer> <Name>Customer1</Name> <Profile> <Version>1.0</Version> <DisplayText>DisplayText1</DisplayText> </Profile> <Profile> <Version>1.0</Version> <DisplayTex...

WPF: How can I wrap the items in a ItemsControl in another Template?

I have an ItemsControl that contains items that each has its own DataTemplate. Each ViewModel class in the ItemsSource derives from a common ancestor that has a Header property. I want to wrap each item in a Expander control, but my problem is that I don't know how to 'carry over' each 'DataTemplate' to the DataContext of the expading p...

What's the easiest way to do negation in triggers?

I want to do something like <DataTrigger Binding="{Binding Something}" ValueIsNot="{x:Null}"> ...

period in XML tags

Studying XAML now, I keep seeing XAML tags in the format Object.Attribute. For example: <Deployment.OutOfBrowserSettings> OutOfBrowserSettings ShortName="Hello World" > Don't recall seeing XML attributes like this before, always would see simple words, or possible a namespace column prefix such as x:application. So, to express a...

BitmapFrame in WPF ComboBox

I have a dialog that lets the user pick a custom icon. Loaded icons are displayed in a combobox in which the user makes the selection. Here is the XAML code for the combobox: <ComboBox Style="{DynamicResource IconComboBox}" ItemTemplate="{StaticResource IconTemplate}" ItemsSource="{Binding Icons, RelativeSource={RelativeSource Fin...

Is it possible to display a wpf window without an icon in the title bar?

As we all know, if the icon for a wpf window is undefined then the default icon is displayed. I want to display a window without any icon in the title bar. I realise that I could use a blank image, however this would cause the text in the title bar to be offset to the right. Does anyone know of a way to completely remove the icon? (I t...

WPF: Cannot set properties on property elements weirdness...

private TextBlock _caption = new TextBlock(); public TextBlock Caption { get { return _caption; } set { _caption = value; } } <l:CustomPanel> <l:CustomPanel.Caption Text="Caption text" FontSize="18" Foreground="White" /> </l:CustomPanel> Gives me the following error: Cannot set properties on property elements....

Embedded images not showing when in a UserControl

I have an Image control that contains a path to an embedded image (build action 'resource'). <Image Source="Assets/images/image.png" Stretch="None" /> If I add that to a container in my MainPage.xaml the image appears fine. When having the same image in a UserControl as shown below, and then adding an instance of that UserControl on M...

Setting DataContext for the root element in XAML without the property element syntax

I was wondering if it's possible to write something like this: <Window ... xmlns definitions ... DataContext=<!--Create an instance here--> ></Window> Instead of this: <Window ... xmlns definitions ... > <Window.DataContext> <local:CustomViewModel /> </Window.DataContext> </Window> I don't need workaroun...

Where can I find good Silverlight application XAML templates & themes ?

Any suggestions would be appreciated. Does not have to be free. ...

WPF DataGrid: Binding DataGridColumn visibility to ContextMenu MenuItems Ischeked (MVVM)

Hi All, I wan't to control DataGrid columns visibility through a contextmenu available to the user by right-clicking the column header. The contextmenu displays the names of all available columns. I am using MVVM design pattern. My question is: How do I bind the DataGridColumns Visibility property to the Ischeked property of a MenuItem...