xaml

How to limit dropdown height for combo box in XAML

What should i do if I want to limit the dropdown height of my combo box to 7? MaxDropdownHeight produces different results for different OS (Operating System); In XP for instance, if I set MaxdropDownHeight to 98, I get desired result, but when I try to test in Vista, its different. How shall I do this when using ComboBox in System.Windo...

How to get number of items in ObservableCollection from XAML?

I'm displaying all of my customers which I get from a ViewModel ObservableCollectoin property within a ComboBox like this: <ComboBox ItemsSource="{Binding Customers}" ItemTemplate="{StaticResource CustomerComboBoxTemplate}" Margin="20" HorizontalAlignment="Left" SelectedItem="{Binding SelectedCustomer, Mode=TwoWay}"...

How can I call javascript functions and pass values from xaml/silverlight?

I'm creating silverlight without visual studio. I just have raw html, xaml, and js (javascript). What I want to do is pass values from the xaml to the javascript. I can call and activate javascript functions from xaml. See below. The canvas element has a mouse left button up event that callls LandOnSpace in the javascript. But ho...

WPF Fade Animation

How would I make a control fade in/out when it becomes Visible. Below is my failed attempt: <Window x:Class="WadFileTester.Form1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="MyWindow" Title="WAD File SI Checker" Height="386" Width="563" Wind...

Setting Command Target in XAML

I am having a hard time understanding the CommandTarget property for a RoutedCommand. Basically, I have some static commands that have implementations in a user control (not the window). I create a commandbinding in the user control. If I declare the button in the usercontrol, then I am able to use my routed event. However, when the ...

Different UI for the SelectedItem and the ItemTemplate for Silverlight ComboBox

Hi all, Basically I'm just looking for a 'SelectedItemTemplate' in the SL3 ComboBox. Unfortunately, that doesn't exist. What I want is for the SelectedItem to look like this: Value And the items in the dropdown box to look like this: Value + extra information The latter is easily enough done by using the ItemTemplate, but the Selec...

How to Bind an XmlDataProvider Class Property to a XAML TreeView

I would like to bind a TreeView control I have defined in XAML to a property in its code-behind class. I already read through a WPF Basic Data Binding FAQ, but the example in the comments at the very bottom of the page didn't work when I tried to use an XmlDataProvider as the binding source. How can I modify the following code so that t...

How can I bind a MenuItem to an ObservableCollection?

I've got this menu bound to an ObservableCollection called MainMenuPageItems, in which there are objects that have a Title property: <Menu DockPanel.Dock="Top"> <MenuItem Header="_File"> <MenuItem Command="{Binding ExitCommand}" Header="E_xit" InputGestureText="Ctrl-X" /> </MenuItem> <MenuItem Header="Code _Generatio...

How to manipulate WPF GUI based on user roles

I am using C#'s Identity and Principal objects for role based security, and I am at the step of modifing controls shown based on roles the current user has. My question is what the recommended method is for enabling/disabling fields in a WPF window - showing/hiding fields dependent on Identity.IsInRole type calls. Can this be done in X...

Accessing to a XAML item from other XAML

Hello, I have a little problem. I have a window that the main content is a UserControl. The user control is a ItemsControl formatting a list. In the window, I have a slider that zoom the ItemsControl. The problem is that in the windows I have created the UserControl, and I have not direct access to the ItemsControl and if I zoom the Us...

Is there a way to insert Silverlight XAML into my page using ASP.NET code-behind?

So, I want to create some Silverlight charts from some data on my ASP.NET web page. The way to do this, either using Visifire (my current thing) or the upcoming Silverlight charting, seems to be to create some XAML, or at least some Silverlight objects (like in this Visifire sample), and then stuff them into the page somehow. Strangely,...

Is there a way to convert WPF binding markup to and from an instance of the binding class?

For example I have the following binding markup Text="{Binding Path=FirstName}" pretty simply but it could be much more complex, I need to be able to parse this markup and get it into some objectified form such as an instance of the Binding class. Something that could work in reverse, an instance of the binding class to spit out the ...

Auto-update of my view

Hi all, I have created an application which has the following: A database created in VS2008, LINQ to SQL A view of the database: XAML part <CollectionViewSource x:Key="CustomerView" Source="{Binding Source={x:Static Application.Current}, Path=Customers}" /> C# part public IEnumerable<Customer> Customers { get ...

How can I tell my DataTemplate to bind to a property in the PARENT ViewModel?

I've got the following MainView.xaml file that works well as a MVVM menu switcher. I've got these pairs: Page1View / Page1ViewModel Page2View / Page2ViewModel in my MainViewModel I fill an ObservableCollection with both ViewModels, then when the user clicks the Next button, it calls NextPageCommand in MainViewModel which switches out...

WPF Canvas Button?

Hi All I'm learning WPF at the moment. I have a vector graphics canvas that I'd like to use as the background for a button, but I can't seem to find a way to do this in the documentation. I thought this would be an obvious thing to want to do. Regards, Mark ...

Toggling between WPF controls

Is there an easy way in WPF/XAML to toggle between two types of controls in the same position in a panel? I'm wondering if there are alternatives to toggling visibilities. In my application I have several checkboxes that are used to configure a bit field (the checkboxes toggle individual bits on or off). Sometimes it is easier for the u...

When user clicks on icon area of MenuItem, DelegateCommand does not fire.

If you use the DelegateCommand in the MVVM Template and build menus dynamically as in the code below, then the DelegateCommand will not fire when the user clicks on the icon area on the MenuItem. Is there anyway to either fix this or make the icon area (to the left of the header) disappear? MainView.xaml: <Window x:Class="TestMenuMvvm...

How to connect ViewModels to their appropriate Views dynamically?

I have a WPF application which has a MainView.xaml Window which loads numerous page objects at runtime, loads them into ViewModels, and displays them dynamically in the menu. My MainViewModel has an ObservableCollection of ViewModels and I bind these each to their appropriate Views in the MainView.xaml file. However, is there a way to ...

What Does this MSDN Sample Code Do? - ItemsControl.ItemTemplate

This is a XAML code sample taken from the MSDN library article for the ItemsControl.ItemTemplate property: <ListBox Width="400" Margin="10" ItemsSource="{Binding Source={StaticResource myTodoList}}"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock Text="{Binding Path=TaskName}" /> <TextBlock Text="{Binding Path=Descripti...

Getting a specific control from a WPF window?

Hi, Is there a way to programatically go through a window's child elements to find one with a certain name? I'm loading xaml dynamically that creates a window and I'm looking to find a "placeholder" control inside it. Thanks! ...