xaml

How can I access DependencyProperty values from my code-behind constructor?

I have a UserControl called SmartForm which has a DependencyProperty called Status. In my Window1.xaml, I have the element <local:SmartForm Status="Ready"/>. I would think then in the constructor of the SmartForm object, that Status would equal "Ready" but instead it equals null. Why is then the value of the Status property NULL in th...

WPF Basics: Shared global styles for MVVM

Hi, I am attempting to use an MVVM-ish approach to my WPF development. I have my logical view model classes under the ViewModel namespace, and I have matching styling for these view model classes under the View namespace. For now I have my View information in ResourceDictionary XAML files, as DataTemplates and Styles, which are all me...

Using WrapPanel and ScrollViewer to give a multi-column Listbox in WPF

Hi I’m making a simple LOB app which loads data from an XML file and displays it in a list with a few buttons for editing. In my first attempt, everything was ok except that the list scrolled downwards in one long column. I would prefer the data to wrap so that at the bottom of the Window it starts a second column, and so on – if you r...

How to bind to a collection contained in an other project/namespace?

i did this: this.combobox.ItemsSource = Common.Component.ModuleManager.Instance.Modules; to bind the combobox to a collection, which is located in an other project/namespace. But i had to move the ComboBox into a DataTemplate. Now i need to do something like that: <ComboBox ItemsSource="{Binding Common.Component.ModuleManager.Instan...

Loading XAML at runtime?

Hi, First some background: I'm working on an application and I'm trying to follow MVVM conventions writing it. One thing I'd like to do is to be able to give the application different "skins" to my application. The same application, but show one "skin" for one client and a different "skin" for another. And so my questions are: 1. Is i...

Refresh Silverlight UserControl via XAML

Hello! I'm using the lastest version of Silverlight 2.0 within Visual Studio 2008. I have a simple Silverlight UserControl with the following code: public partial class SilverlightControl1 : UserControl { public SilverlightControl1() { InitializeComponent(); this.Loaded += new RoutedEventHandler(SilverlightContr...

Mixing dynamic and static XAML menu items.

I have a scenario in which I need to have both static and dynamic menu items. The static items will be defined in XAML and the dynamic ones supplied by a View Model. Each dynamic item will itself be represented by a VieModel, lets call it a CommandViewModel. A CommandViewModel has amongst other things a display name, it can also contai...

LoadComponent() Vs. XamlReader.Load() ?

Hi, Related to an earlier question I asked, I've seen that there's both LoadComponent() and XamlReader.Load(). They're similar enough that I'm not quite sure which one I should use in what case. So, in essence, what's the difference between the two? Thanks! ...

How can I change the Visibility of a TextBlock with a Trigger?

When I try to compile the following code, I get the error 'Visibility' member is not valid because it does not have a qualifying type name. What do I have to change so that I can make the TextBlock disappear when Status=off? XAML: <Window x:Class="TestTrigger123345.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/prese...

How can I convert this TextBlock fade-in trigger to a Style

This XAML makes text fade in when it appears. I would like to put this functionality into a Style. However, but what do I put in for the "TargetName" since the style doesn't know which element is going to be using it? How can I convert this fade-in effect to a style? <TextBlock Name="Message" Text="This is a test."> <TextBlock.Trig...

How can I get a trigger to change the color of a TextBlock based on a DataContext Property?

Why does the following code get the runtime error Members of the Triggers collection must be of type EventTrigger? But the EventTrigger element doesn't have a Binding property. So how do I change the color of the TextBlock based on the DataContext Property? XAML: <Window x:Class="TestTrigger123345.Window1" xmlns="http://schemas.m...

How can I use a XAML trigger to say great-than-or-equal-to a value?

I can create simple triggers that check if a property has a specific value like this: <Style x:Key="StatusIndicator" TargetType="TextBlock"> <Style.Triggers> <DataTrigger Binding="{Binding Status}" Value="off"> <Setter Property="TextBlock.Foreground" Value="Red"/> </DataTrigger> </Style.Triggers> </St...

How can I apply multiple XAML styles to one element?

I have a toolkit:DataGrid (from Codeplex). It is starting to have many different styles: one for switching it on and off based on a variable in the ViewModel one for visual styling one for some other triggers, etc. Do all of these need to be in one big style, is that the only way to do it? Or can I have multiple styles and attach th...

Silverlight 3/Prism - Passing an enum value as a Command Parameter

I'm trying to use Prism and the MVVM pattern to develop an application. In my UI, I have a previous and next button defined. For use in a calling web services, I've defined an enum that will tell me the direction I need to traverse. So, in this instance, the buttons map directly to an enum value. The enum definition is very simple a...

Setting Window.Content doesn't destroy the UI that was there before?

Hi, I'm loading a XAML file with XamlReader and setting the returning object to the window's Content property. While this seems to work well, it doesn't quite do what I expect. If the window's original XAML contains keybindings or buttons, they seem to still exist. Keybindings still work and any Button objects in code are still valid. I...

SelectedItem Trigger

Can I use a trigger on the SelectedItem property in any control that supports SelectedItem? <Trigger Property="SelectedItem" Value="{x:NotNull}" > </Trigger> What I want is when the SelectedItem is Not null for the trigger to fire. Tnx ...

Linked Files within a Folder Structure

In Visual Studio when I linked a file from one project to the next, I get the following error when an attempt is made to load the linked resource. This only happens when the linked file is within a folder(s). Error: Message="'pack://application:,,,/projectName ;component/ResourceDictionary .xaml' value cannot be assigned to property '...

Passing the current mouse position to a ViewModel?

Hi, In my MVVM application, I have a Direct3d render window that shows a bunch of 3d meshes in a scene. In that render window, I want to be able to click on one of those 3d meshes in the scene and move it around, having it follow the mouse cursor. This is typical 3d editor stuff, moving a mesh along in screen space. So I need to be able...

Trying to rotate text for a groupbox

I'm trying to create a groupbox-like element in XAML (for a Silverlight 2 app) but with a twist. Normally a groupbox would consist of a border, with the main content placed inside the border, and a header content placed over the border itself. What I'm trying to do is place the header text over the left side border, rotated 270 degree...

Building a MVVM 3D Editor Application -> Getting Mouse Position?

Hi, In my 3d editor application, I want to be able to click on and move a scene's entities (meshes, lights, cameras, etc). To do that, I imagine that I need to get the current mouse position relative to my Direct3d view and somehow give it to my ViewModel. How would I go about doing that, considering that my app is built with the MVVM p...