xaml

Serialize xaml in silverlight

Hi, I need to serialize a specified element of my xaml markup in silverlight. I've used the silverlightcontrib library and the xamlwriter class that has, however when trying to load a textbox control back an error is thrown stating that a textbox cannot contain content. Upon inspecting the xaml file that is produced, the textbox elemen...

Is there a way to re-use an already closed WPF Window instance

I have a Window instance which I show by calling wInstance.ShowDialog() from a button click and I close the window by pressing Alt+F4. The issue now is that I cant call wInstance.ShowDialog() again. How can I re-use the same window instance again. Exception : Cannot set Visibility or call Show or ShowDialog after window has closed. ...

WPF DataGrid column widths and reordering

I have a DataGrid defined as <wpftoolkit:DataGrid x:Name="AccountsDataGrid" AutoGenerateColumns="False" ItemsSource="{Binding Path=Accounts}" ColumnReordered="DataGrid_ColumnReordered" SelectionUnit="FullRow" RowHeaderWidth="0" HorizontalAlignment="Stretch" VerticalAlignmen...

How can I access my View elements via x:Name from my Presenter?

My presenter defines its own view: public SmartFormPresenter(SmartFormView view) { View = view; View.DataContext = this; } In the view I have an element with x:Name="MainTabControl": <DockPanel LastChildFill="True"> <TabControl x:Name="MainTabControl" DockPanel.Dock="Top" ItemsSource="{Binding SmartFormAreaPresenters}"> ...

What is the syntax to define view/presenter pairs in XAML?

Why is that when I define a view with data context in this way: <views:MessageView DataContext="{x:Type presenters:MessagePresenter}"/> that my MessagePresenter does not run its constructor? What is the syntax to define view/presenter pairs like this in XAML? ...

Overriding styles in silverlight from XAML fetched from database

Within my App.xaml I have the following segment: <Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="Assets/Styles.xaml"/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Application.Resources> I want to be able to overrid...

Accessing codebehind object in XAML

Hello, Another post describes how to access a codebehind variable in XAML. However, I'd like to access a variable in codebehind object from XAML. The codebehind object, called FeedData, is declared as a dependency property of type FeedEntry. This class is just a container class with string and datetime properties. Codebehind's proper...

Silverlight DataGrid Refresh Between Xaml Files

Hello, I have a Page.xaml file and a AddNewProject.xaml. In the Page.xaml file I have a ProjectDetailsDataGrid and a button to add a new Project. When I click on the Add New Project button the AddNewProject.xaml file becomes visible for the user to enter new project information. I am having a problem trying to refresh the ProjectDeta...

WPF issue with TreeView and Popup controls

When using a Popup inside a TreeView in WPF I am running into an issue where the controls inside the popup become unusable. For example, using the following code the ToggleButton inside the popup can only be toggled once and then becomes unable to be toggled back. Is there any way to work around this issue? <Page xmlns="http://schemas.m...

What does the runtime do with XAML namespaces?

In every XAML document, there are one or more namespace declarations. ie: <Window x:Class="WindowsApplication1.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1 Height="300"> The declarations are in the form of a URL, leading me to ask: Does...

How to use a defined brush resource in XAML, from C#

So far I have this <UserControl.Resource> <LinearGradientBrush x:Key="KeyDownBrush" .....> Now I would like to access this defined resource when a key is pressed and replace the current objects fill with the KeyDownBrush, in C#. I've tried this.Resource.Contains("KeyDownPress") and have been able to get True returned so I presume I ...

What is the simplest method to change the desktop with one click

I have a window with WindowStyle="none" and WindowState=Maximized" and now I'd like in my contextmenu set the MenuItem to switch the application to the other desktop. whats the simplest way to do that? ...

What is the easiest way to style the ScrollViewer in XAML

I would like style my ScrollViewer (background, arrows...) What is the easiest way to do that? Has someone a couple of good and simply examples for this? (the article from sachabarber know it, but for my purposes too complex) ...

Superscript / subscript in hyperlink in WPF

I'm trying to make a Hyperlink that contains text with super- and/or subscripts. I've found two ways to do this, and both of them suck. Solution #1: use Typography.Variants. This gives a terrific superscript... for some fonts. <StackPanel> <TextBlock FontFamily="Palatino Linotype" FontSize="30"> <Hyperlink>R<Run Typography.Varian...

Can I use XamlReader.Load or InitializeFromXaml from a WPF Window, for the Window definition?

I want to produce some library code that will be included into WPF applications. The library may pop up a Window, depending on circumstances. I can define the Window in XAML, but I'd like to treat the XAML as a template. At runtime, at the time the Window is being created so that it can be displayed, I want to replace certain tags in t...

Is it possible to apply Blend behavior using style or template?

I'm very happy with my small collection of Blend behaviors, actions and triggers - they are easy to use and powerful. But I still can't figure out how to avoid applying them on per element basis. For example, if I have a behavior as such: <Rectangle> <i:Interaction.Behaviors> <il:MouseDragElementBehavior/> </i:Interactio...

Adding Grid and Controls dynamically in WPF.

I am now doing an application that shows the HDD usage in the system. For that I want to generate the grid and the controls (like progress bar and labels) dynamically to show the usage. Is there any XAML template available for this purpose? ...

Update a XAML control template from C#

I have a control template in XAML that contains a listview with a gridview. I want to bind the listview to a datatable created within C# but I can’t see the listview to do this because it is within a control template. I’ve created the equivalent listview in C# by referencing the control template and its contents and thought that I would ...

Silverlight XamlWriter

I see that the .Net XamlWriter is not available in Silverlight. Well - I need one anyway, so I assume there is a solution to this..? I have some UIElement objects (Path, Ellipse, Rectangle, ..), and I want to store their Xaml definition such that I can load these later using XamlWriter.Load(). Any ideas on how to do this? Any 3rdParty ...

In a WPF tabControl how can I dynamically select a tab page from an object's type?

I've implemented the MVVM pattern and have some viewModels that are bound to tab pages on a tab control. When a specific object type changes (i.e. from Car myVehical, to Bike myVehical), then i want the relevant tab page to become selected. Thanks. ...