xaml

XamlXmlReader.Read() does not yield matching XamlNodeType.StartObject and XamlNodeType.EndObject on .NET 4.0 RC

Hi, I am trying to parse a valid xaml file using the XamlXmlReader. It looks like it is 'skipping' some elements when when Read() is called. for example on the following xaml snippet: <UserControl.Resources> <Converters:AnyDbTypeToDisplayNameConverter x:Key="anyDbTypeToDisplayNameConverter" /> </UserControl.Resources> when r...

WPF Grid Row / Column Sizing in Proportion to DesiredSize?

I have two user controls arranged vertically in a grid, both of which can expand to be taller than the grid can accommodate. I've put them in each in a scrollviewer which functionally works. What I want though is to give them them space in proportion to the amount that they want at run time. So if there's 500 height available, the upper...

Should I inherit from a stackpanel instead of a stack panel, grid or other UI element or UserControl?

So I'm building a peice of UI that might me in a dialog window or might be in embedded in part of a bigger page. I don't have alot of experience with WPF, but in ASP.NET you always used UserControls, because their wasn't anyt really generic UI inherit to inherit from (and in a way UserControl was just a div). My coworker has written ...

Modify a ListBox's item from a button in it's template?

In my Silverlight 3 project, I'm using a ListBox to display results of a Get() operation form a WCF WebService. The ListBox's item template is the following : <ListBox x:Name="m_listview" ItemsSource="{Binding Users, Mode=TwoWay, UpdateSourceTrigger=Default}" Foreground="{StaticResource EnergyBlue}" Background="{StaticResource EnergyBa...

Measure label size

I'm implementing a custom control with some labels on it and I need to measure the size of those labels to have an optimal layout. In this way I can properly show the control for each font and font size. Could you tell me how can I do that, please? Thank you. ...

Translate ImageButton from C# to XAML

I worked out the C# code to create an ImageButton (below) that has three images (one base-image and two overlays) and three text boxes as the face of the button. I am inheriting from the Button class, which unfortunately includes several components that I didn't realize would surface until after coding and need to remove, namely the bri...

Pass or Get a value from Parent ViewModel down to Sub-ViewModel?

I am using the MVVM Light framework as well as Unity for DI. I have some nested Views, each bound to a corresponding ViewModel. The ViewModels are bound to each View's root control DataContext via the ViewModelLocator idea that Laurent Bugnion has put into MVVM Light. This allows for finding ViewModels via a static resource and for contr...

Use XAML data binding to bind each end of a Line to the center of two shapes on a Canvas

I have a Canvas in Silverlight with two ellipses on it. The ellipses are animated via events in the code behind. I have added a line two the canvas and I would like each end of the line to be bound to the center of each ellipse. Is it possible to do this in XAML databinding or will I have to manually move the end of the line around in...

Override default markup extensions

I have written custom markup extesions, but what if I need to override an markup extension already defined? For example, I need to serialize StaticResources references and not the values when using XamlWriter.Save(object obj) method, so I guess what I need is to write a custom markupextension inheriting from ‘StaticResourceExtension’ tha...

WPF TextBox SpellChecking Problem

How can I change the spellchecking language of a WPF textbox to french using XAML? I tried this but it doesn't work. <TextBox AcceptsReturn="true" SpellCheck.IsEnabled="true" FontSize="12" BorderBrush="Blue" Height="100" Language="fr-fr" /> French is supposed to be one of the 4 supported languages for spellchecking in WPF so I don't u...

Is there a measurestring equivalent in Silverlight xaml?

What I am trying to accomplish: Create a dynamic bubble that expands on height and width depending on the amount of text in the bubble. What I researched so far: In a SO article they described utilizing the measurestring function to figure out the exact width or height so dynamic changes in the .cs to the width and height can be accompl...

Dependency Property on ValueConverter

Using Silverlight 4, I'm trying to initialize a converter in the Resources section of my UserControl with a reference to one of the objects in my control. When I try to run the application I get this exception, note Line 16 in the actual XAML file is the converter:PointConverter.... line: System.Windows.Markup.XamlParseException: 2260 A...

Storyboards in ResourceDictionary

So I would like to move my Storyboards into a ResourceDictionary file and I am having trouble doing that. I have looked everywhere and it involves making the "Resource" sharable but how do I do that in silverlight when there is no x:Shared attribute. Here is the code <Storyboard x:Key="GreenButtonLight" > <ColorAnimationUsingK...

What is a good way to factor out and simplify a complicated WPF custom control?

I am looking for a good way to simplify and organise a complicated WPF custom control. My first thought is to factor it out into two simpler controls. For the sake of explanation I'll call these SimpleControl and AdvancedControl. SimpleControl contains all the core functionality and is extremely reusable. AdvancedControl depends u...

Adding custom properties to Silverlight controls

Hello, What is the best way for me to add my own properties to an existing Silverlight control? For example I would like to associate a custom class with the DataGrid and be able to set the properties of this custom class in Expression Blend? Is this an easy thing to do? Thanks, AJ ...

WPF Lookless Control Events

I have the following class: public class LooklessControl : Control { public List<int> IntList { get; private set; } public int CurrentInt { get; private set; } private int _index = 0; static LooklessControl() { DefaultStyleKeyProperty.OverrideMetadata(typeof(LooklessControl), new FrameworkPropertyMetadata(t...

Setting a Silverlight textbox control's width relatively

Hello, I tried searching on stackoverflow for an answer to my question but couldn't seem to find anything relevant. Since I'm relatively new to Silverlight, I'm not even sure if this is possible, but I am trying to figure out if it is possible to set a Silverlight textbox control's width value proportionally to it's immediate parent co...

XAML and WPF - Passing Variables to XAML Windows

Hi, I'm pretty new to WPF and i'm trying to load a XAML window and pass a variable to this XAML in its constructor or so, because i need it to load some items from this passed variable. Could anyone point me to the direction of how to go about this please? How does one start up a XAML window and give it a variable please? Thanks in ad...

WPF UserControl Style results in error message

Hi I'm new in WPF so I try to create a WPF UserControl. My problem is about the style of the user control I've Created. On a design time I got this error message Can only base on a Style with target type that is base type 'RichTextBox'. at System.Windows.Style.Seal() at System.Windows.StyleHelper.UpdateStyleCache(FrameworkElement...

How to change button background color depending on bound command canexecute ??

Hi, I Have a ItemTemplate in which is a simple button bound on a command, which can be executable or not depending on some property. I'd like the color of this button's background to change if the command isn't executable. I tried several methods, but I can't find anyway to do this purely in XAML (I'm doing this in a study context, and...