xaml

References to Controls in ContentControl are null at the Parent (Page) Level

As a follow up to this question where it was suggested I use a ContentControl, I have run into a scenario when I use a custom made class that dervies from ContentControl on a page, any controls defined within that ContentControl are not accessible from the page. All member variables turn out null. For Instance, say the custom class I cr...

WPF - Dialogs using MVVM

Hi! When using custom dialog windows in a MVVM application, do you think it´s Ok to use the code behind to handle properties, events etc.? Or should I always have a ViewModel binded to every dialog view? What´s your thought? ...

Loaded XAML Not Binding to Existing Elements Correctly

I have a button that loads XAML from a file, creates a control from it and adds this control as a child to a canvas that is part of a template present in the resources of a dockpanel on the window. The window also has a combobox named cboTColour and a combobox named cboBColour which I use to set a simple gradient background on my loaded ...

Binding to another element within object creation in XAML

I have a control in which I am creating a specific Command class in XAML, and it needs a reference to a ContentControl element that is declared later in the XAML. I have the relevant property of the command object bound to the ContentControl via its ElementName, but at runtime, it doesn't seem to get the ContentControl (the command's pro...

Data loss during WPF clipboard operations

I am working with a FlowDocument in a WPF RichTextBox. Some of the flow document elements are created using subclasses of the System.Windows.Documents framework classes and all of the elements use the Tag property to store additional data. If I use a XamlWriter to serialize a document tree, everything is correctly reflected in the resul...

Building a dynamic TabControl in Silverlight

I would like to build a TabControl in Silverlight which is driven by a collection of objects. I'll show the code below of a VERY basic setup that I'm trying to prototype. MainPage.xaml <UserControl x:Class="DataDrivenTabControl.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.micros...

Determining XAML parse error locations on CE

We're evaluating using Silverlight on C++ for an embedded project and are prototyping some screens for a demonstration. What I'm finding is that Expression Blend will create XAML files that work fine on the desktop but, when porting them over to the CE device results in parse errors (apparently not all tags and elements are supported on...

Determining the Enter key is pressed in a TextBox in Win Phone 7

Consider a XAML TextBox in Win Phone 7. <TextBox x:Name="UserNumber" /> The goal here is that when the user presses the Enter button on the on-screen keyboard, that would kick off some logic to refresh the content on the screen. I'd like to have an event raised specifically for Enter. Is this possible? Is the event specific to...

Bind TextBlock in DataTemplate (resource) to Content of checked radio button

I have a TextBlock in resource data template: <DataTemplate x:Key="MyDataTemplate" ItemsSource="{Binding MySource}"> <TextBlock x:Name="MyText" Text="{Binding ???}" /> </DataTemplate> that I want to bind with Content of checked radio button: <RadioButton GroupName="MyGroup" Content="Code" /> <RadioButton GroupName="MyGroup" Conte...

How to initialize UserControl's CLR property in the following case?

I’ve created UserControl: public partial class MyTemplate : UserControl { public MyUser User { get; set; } } And then have written the following code in the main window’s xaml <Window.Resources> <DataTemplate x:Key="My"> <local:MyTemplate Margin="10"/> </DataTemplate> <Window.Resources> <ListBox x:Name="MyMainList"...

adding a custom namespace to xaml

i am quite new on c#, wpf and xaml etc then i may not be able to use the right terms to ask the right question=) i am trying to add my own namespace to my xaml file in order to use my own class easily-i guess the reason is this- i wrote that command in window tag for this: xmlns:myns="clr-namespace:LibNameSpace" where my window tag als...

save bindings to XAML

According to Microsoft, http://msdn.microsoft.com/en-us/library/ms754193.aspx#Extension_References_are_Dereferenced bindings are not serialized to XAML when using XamlWriter. Has anyone implemented a way to save these bindings to XAML? ...

Are recursive DataTemplates possible?

I have a class something like: public class Section { private IEnumerable<Section> sections; private IEnumerable<KeyValuePair<string, string>> attributes public string Name {get;set;} public IEnumerable<Section> Sections { get {return sections;} } public IEnumerable<KeyValuePair<string, string>> Attr...

Cannot find a public type named PresentationUIStyleResources

I am new to WPF and XAML, but after a few hours of googling I cannot figure out what is wrong here. I have PresentationUI assembly added as a reference. "The type reference cannot find a public type named 'PresentationUIStyleResources'. Line 14 Position 44." The error occurs on the first line with 'PresentationUIStyleResources'. What...

Cannot convert string 'Top' in attribute 'VerticalAllignment'

I am getting following error randomly. cannot convert string 'Top' in attribute 'VerticalAlignment' to object of type 'System.Windows.VerticalAlignment'. Top is not a valid value for VerticalAlignment. Please suggest what could be causing this error to come up and why it is so random. <ProgressBar Margin="10" Name="PBar" H...

How to create DataTemplate with Links

Hi, I'm trying to create DataTemplates for a PropertyCollection (of PropertyDescriptors) to display the items in the collection in this format, descriptor1 > descriptor2 > descriptor3 > descriptor4 > descriptor5 Each descriptor would be a link (using Hyperlink), my question is can I do this with Labels (which is not an ItemsControl ho...

How to force Visual Studio 2010 to ignore a WPF XAML declared DataContext at design time?

Quite often I will set up WPF UserControl with a declarative DataContext: <UserControl...> <UserControl.DataContext> <local:SomeModel x:Name="Model" /> </UserControl.DataContext> </UserControl> When in design mode, Visual Studio will attempt to instantiate the DataContext. However, when the DataContext is pulling data ...

How to write DataTemplate to display xaml

Hi, I need to display xaml code in a panel, how do I write DataTemplates to format the xaml with proper indentation and hyperlinks for references (such as StaticResource etc), for example, <ListBox ItemsSource="{Binding}" ItemTemplateSelector="{StaticResource ResourceKey=selector}"> <ListBox.ItemsPanel> <ItemsPanelTemplate> ...

ListBox template tweak needed for horizontal stretching of listbox items

I am trying to use a DataTemplate for ListBox.ItemTemplate for a simple TODO list. The template for each ListBoxItem is a grid and I want the content for my 2nd column to stretch the remaining width of the listbox. No amount of HorizontalAlignment="Stretch" etc. etc. seems to do the trick and I think I need to modify the template. I've ...

Grouping with collectionviewsource based on 2 columns

Hi I've a collection with itemname and header, and I've to group based on header, and if the header is empty the group style must be a button, or else it should give expander and the itemnames as its content. {itemname="cadbury" header="choclates"} {itemname="5 star" header="choclates"} {itemname="Flapjack" header=""} {itemanem="ford" h...