xaml

How to inherit XAML style and override property of child element?

Hello, we just got started with XAML and are still fighting with basic issues: Coming from CSS we'd like to define a generic button style with custom control template and then have a second style inherit everything from the first style using "basedon. This second style should then override properties such e.g. "foreground color" (which ...

Setting a custom property within a WPF/Silverlight page

This sounds like it should be simple. I have a Page declared in XAML in the normal way (i.e. with "Add new item...") and it has a custom property. I'd like to set that property in the XAML associated with the page. Trying to do this the same way that I'd set any other property doesn't work, for reasons I understand but don't know how to...

Make XamlReader.Load ignore unknown xml instead of crashing?

How do I make XamlReader.Load to just ignore unknown attributes and elements instead of throwing exceptions? It would be much more useful if it only ignored those. ...

Can a WPF Style be used to apply currency formatting to a DataGrid cell?

I've got a WPF DataGrid and wish to apply a currency format to several of the columns. I can do this on a per-column basis using Binding={Binding FieldName, StringFormat={}{0:C}, but I'd prefer to define the currency format once - presumably in a <Style> resource - and just apply that resource to each column that needs formatting. Probl...

XAML reference control and properties in x:Array

<RichTextBox x:Name="OrigText" Margin="0,0,8,0" d:LayoutOverrides="Width"/> <Button x:Name="OrigFileBrowse" Command="{Binding BrowseCommand}" CommandParameter="{Binding ElementName=OrigText, Path=Document}" HorizontalAlignment="Center" Margin="0,0,8,2.442" Width="75" Content="Browse" Grid.Row="1" d:LayoutOverrides="Height"/> <Ric...

WPF command - called from Window and UserControl, same handlers

How can I have a Command that can be called from both a Window and a UserControl (by hitting a button in either) that uses the same execute and can-execute methods? It seems like if I have the following in my UserControl's XAML, it requires myCommandHandler and canExecuteMyCommand to be in my UserControl class: <CommandBinding Command=...

Custom WPF ValidationRule throws Visual Studio DesignTime error

I've created a custom assembly that has some ValidationRules for regular expressions and required fields. As soon as I start using them in XAML, Visual Studio Designer throws the following error. System.Reflection.Adds.UnresolvedAssemblyException Type universe cannot resolve assembly: Validation, Version=2.0.0.0, Culture=neutral, Public...

WPF FlowDocument Binding

I am using Microsoft's XAML/HTML converter to convert HTML from a database into a XAML string. The Microsoft converter seems to be formatting the text correctly, but I'm having trouble binding the output to a XAML object. For example, using the following HTML: <span style="font-weight: bold; font-family: Georgia; color: rgb(0, 96, 144...

WPF - ItemsSource equivalent for Table in FlowDocument?

I'm trying to create a Table inside a FlowDocument inside a FlowDocumentPageViewer, as seen in this tutorial. I've never created a table in WPF before, and I was expecting there to be an ItemsSourceproperty to which I could bind, like with a ListBox. I want to customize the template for each row, and I want each row's source to be an i...

Animating background color of border in Silverlight, State precedence in VisualStateGroups

This is a silverlight/XAML question. Not sure what I'm doing wrong, this seems to throw an error: <ColorAnimation Storyboard.TargetName="btnRemoveBorder" Storyboard.TargetProperty="Background" To="#FFDEBA29" Duration="0" /> 2nd question is... rather confused with the Selected and Focused states. Can one state take precedence ove...

Issue with control layout when using Validation.ErrorTemplate

I have a custom control which is hosted in a Window with some other controls on it. The custom control and the window are in different assemblies as the custom control is to be shared across several applications. Within the window I define a style for type FrameworkElement and then in that style I set the ControlTemplate to utilize an ...

WPF Styling border thickness on trigger...

I have the following style defined... <!-- Blue Button --> <Style x:Key="BlueButton" TargetType="{x:Type Button}"> <Setter Property="OverridesDefaultStyle" Value="True"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="Button"> <Border Name="border" BorderThickness...

How to center image in MultiScaleImage

Found the function which position the image(s) in the multiscaleimage... but I'm not sure how to get the actual image width (for single or multiple) and change the _msi.ViewportOrigin x param based on that. There are 2 lines which affect the image position... one is _msi.ViewportOrigin = new Point(0, 0); and the other is: //if (lay...

Drag N drop images in a viewbox

I have a usercontrol with 6 viewbox, each can have an image. I have not set the width or height of the usercontrol(not even the viewboxes). At first the viewboxes are empty.I can add the images dynamically. <Grid x:Name="DashBoardGrid" DockPanel.Dock="Right"> <Grid.RowDefinitions> <RowDefinition Height="20"></RowDef...

WPF User Controls and DataBinding

Hi all, I guess I'm a bit stuck on the mechanism of WPF DataBinding. Up to now I've thought of it as this : Any target of a DataBinding has to be a DependencyProperty.Keeping that in mind, I designed a very simple button-based UserControl like the following (boiled down to the most necessary parts): XAML <Button x:Class="MyNamespace.I...

Error: The name 'tBox' does not exist in the current context.

Error: The name 'tBox' does not exist in the current context. XAML: <ItemsControl Name="itemsControl"> <ItemsControl.Template> <ControlTemplate> <WrapPenel> <ItemsPresenter/> </WrapPenel> </ControlTemplate> </ItemsControl.Template> <Item...

Using xaml resources, but keeping unique content per reference

I have several ListBoxes and have set up the group style to make the groups expanders. I want all of the ListBoxes to use the same style information to make them all expanders, but i want to be able to change the content of the header to be custom for each use of the style. Is there any way i can take the out of the but still edit the...

WPF / Silverlight - selected row style on DataGrid

What is the best way to get a row-by-row selection feel to a DataGrid in Silverlight rather than a selected row and an active cell? For my current application I just don't need the UI effect of an active cell. ...

RelativeSource binding from a ToolTip or ContextMenu

What am I doing wrong here?: <GridViewColumn> <GridViewColumn.CellTemplate> <DataTemplate> <Button> <Button.ToolTip> <TextBlock Text="{Binding Path=Title, RelativeSource={RelativeSource AncestorType=Window}}" /> That's just a simplified example, that doesn't work anyway :) Actually I ne...

Is there any way to create a sticky footer in xaml?

I know you can do a sticky footer in css, is there any way to do it in xaml? Or to use css in xaml to do the same thing? I'm brand new to xaml, so any help would be appreciated. ...