xaml

How can I make an "Accordion Widget" in WPF?

The goal: I'm trying to achieve something like this in WPF: An initial solution: At the moment, I'm trying to use an ItemsControl with an ItemTemplate composed of an Expander. I want a consistent look for the Header portion of the Expander, but I want the Content portion of the Expander to be completely flexible. So, it's basical...

WPF ItemsControl: Can't seem to get items to display in the view

The code I'm working on is part of a WPF application that should display a set of stacks of playing cards that the user can interact with. So there's three UserControls I'm working with: MainControl CardStackControl CardControl In MainControl.xaml: <StackPanel Grid.Row="0" Orientation="Horizontal"> <Ite...

In WPF, how can I inherit from ToolBar AND have a XAML file?

I can inherit and enhance the ToolBar class by creating a plain C# class, then doing this: public class NiceToolBar : ToolBar { private ToolBarTray mainToolBarTray; public NiceToolBar() { mainToolBarTray = new ToolBarTray(); mainToolBarTray.IsLocked = true; this.Background = new SolidColorBrush(Colo...

Is there a way to use WPF Grid without specifying absolute cell coordinates for every item?

My typical form with Grid look like this in XAML: <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"></ColumnDefinition> <ColumnDefinition></ColumnDefinition> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="Auto"></RowDefinition> ...

WPF - How can I place a usercontrol over an AdornedElementPlaceholder?

I'm trying to get the validation to not show through my custom modal dialog. I've tried setting the zindex of the dialog and and of the elements in this template. Any ideas? This is coming from a validation template: <ControlTemplate x:Key="ValidationTemplate"> <DockPanel> <TextBlock Foreground="Red" FontSize="20"...

Change Property from within event trigger

What I want is simply that all my TextBoxes as by default set their cursor at the end of the text so I want in pseudocode: if (TextChanged) textbox.SelectionStart = textbox.Text.Length; Because I want that all textboxes in my application are affected I want to use a style for that. This one won't work (for obvious reasons) but you get...

WPF (MVVM): Wiring up viewModel to view in code-behind of Window?

Hi there, I have been getting my feet wet with MVVM pattern for WPF and everything is working as it should.. But i am wiring up the viewmodel to my view datacontext from my codebehind of my window. Sure enough the point of MVVM is to get rid of code behind in windows... which it does great, so i am left with 2 simple lines to wire up...

Underline Label in WPF, using styles

I have the following style: <Style x:Key="ActionLabelStyle" TargetType="{x:Type Label}"> <Setter Property="Margin" Value="10,3" /> <Setter Property="Padding" Value="0" /> <Setter Property="TextBlock.TextWrapping" Value="Wrap" /> <Setter Property="FontFamily" Value="Calibri" /> <Style.Triggers> <MultiTrigger>...

wpf debugging xaml

As part of learning wpf I'm working through some MS 'lab' sample apps; The finished exercise looks right, but I'm hitting a NullReferenceException with "Source code unavailable" issue (exception detail below). It appears to be thrown after the main window is shown. I suspect the issue is in the XAML, but the debugger isn't helping me a...

Align top-left corner of VisualBrush's Visual into top left corner of rendered area

I am using a VisualBrush as part of a control template. I want the image to not be tiled or scaled, and the top-left corner of the target visual to be aligned to the top-left corner of the rectangle I am filling. The trouble is, without specifying absolute Viewbox units, I can't make this happen, and I can't use absolute viewbox units in...

Binding to AssemblyVersion in XAML (for Help/About dialogue)

Maybe I'm expecting too much here, but I figure I can't be the first person to have tried. Do I have to create (yet another) converter for this? ...

WPF DataGrid binding problem

Lets say we have the following code in XAML (the datagrid is bound to an ObservableCollection and the column to a property of the ObservableCollection: <WpfToolkit:DataGrid ItemsSource="{Binding Path=Collection}" HorizontalScrollBarVisibility="Hidden" SelectionMode="Extended" CanUserAddRows="False" CanUserDeleteR...

Online or free learning resources for Silverlight Styling

Hy i'm looking for these types of learning resources. One that is explaining the basics of the Silverlight styling(Basic Terms). Or some very simple collection of examples,in wich i can learn a lot. And one is that is very similar to Silverlight Documentation (ex. what property do you need to set if you want have this modification),ex...

Did I just find a bug in WPF?

Paste this into Cider. <Grid x:Name="Grid"> <Grid.ColumnDefinitions> <ColumnDefinition x:Name="ColumnDefinition"/> </Grid.ColumnDefinitions> <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"> <TextBlock Text="{Binding ActualWidth, ElementName=Grid}"/> <TextBlock Text="{Binding Actual...

xaml injection (modify) from code behind file means dynamically

hi, I am working on NHibernate with wpf. I want to inject (insert) XAML from code behind file. for example I have a xaml grid at user interface level. Now i want to enter xaml string in xaml grid tag from code behind file. How can i achieve that? I want dynamically insert/remove xaml from .cs file. please help. ...

Overriding styles defined in generic.xaml

I have a custom controls library, in which I defined a control template, that uses some custom styles. My control template is located in the Generic.xaml file, and the styles it uses are also located there, and accessed by the control template with the StaticResource markup extension. In some cases, when I use this controls library, I wa...

How to do validation on a TextBox in Silverlight, end-to-end?

I'm trying to add Validation to a Silverlight 3.0 TextBox but cannot seem to find and example which is complete, and not missing functionality that makes it work, I have this property: ''' <summary>Tag</summary> ''' <value>String</value> ''' <returns>String</returns> ''' <remarks>Contains Validation</remarks> Public ...

Allowing to add elements to a list in xaml

I've created a custom control that I insert into my window with the following code <controls:ListExpander Text="Class Diagrams"></controls:ListExpander> The control in question contains several subcontrols, among others, a list. How can create the setup, so I can specify items that should be added to the list? Eventually I'm looking f...

How can I set the selected property in a custom user control which inherits XAML ComboBox?

I've built a custom user control which inherits ComboBox and has items which are KeyValuePair<bool, string> I want to set the boolean default value of this ComboBox so that when true it shows "Yes" and when false it shows "No". In the code below, when I set the selected value to true, then the ComboBox correctly shows "Yes". But wh...

Why do I get a XamlParseException when I inherit a Custom UserControl in another project?

In one project I have an Editor Class: namespace TestXamlInherit234 { public class CustomerEditor : BaseEditor { public CustomerEditor() { TheMessage.Text = "changed222"; } } } which inherits from a WPF User Control in another project: using System.Windows.Controls; namespace Core { ...