I was looking at MEF as an extensibility framework, and I'm pretty much sold, except for one point:
Let's say I want to import both a ViewModel and a View to display it. I think the "right" way to do that is for the MEF part to export a ViewModel class, and a DataTemplate that displays the ViewModel. As an example, say you were buildi...
The actual visuals are dictated by a DataTemplate. In runtime, how can I iterate through all the visual elements of a ListBoxItem?
...
I have a DataTemplate containing an Image. To the Image I added a ContextMenu with a MenuItem. To the MenuItem I associated a command. I then handle the command in the view using the DataTemplate.
In the CanExecute handler I have e.CanExecute = true. But the Executed handler is never executed. If I remove the Command assignment the Men...
I am trying to use the MVVM pattern for the first time. So I have an ItemsControl filled with my viewmodel objects, displayed using DataTemplates; the objects are "nodes" and "edges" represented in DataTemplates with Thumb and Polyline objects, and I want to be able to detect clicks and drags on the ItemsControl in order to move the node...
I have a context menu. It's bound to some collection and it has a defined ItemTemplate like this:
<ContextMenu
ItemsSource={Binding ...}
ItemTemplate={StaticResource itemTemplate}
/>
itemTemplate is a simple DataTemplate with a TextBlock:
<DataTemplate x:Key="itemTemplate">
<TextBlock Text={Binding ...} />
</DataTempl...
I have a ListBox displaying employees with a DataTemplate - it looks very similar to this screenshot. I want to be able to click on the employee photo, drag it and drop it somewhere out of the ListBox. How can I do that? I am not sure how to capture the PreviewMouseLeftButtonDown event of the Image, since it's inside the DataTemplate.
E...
Is there a way to place something (a custom UIElement) in place on the right of TabItems' headers, so that the headers will consider its size.
I feel like there should be a data template for them, but I do not know what to read or how to query google for that.
...
Hi, I am using an ObjectDataProvider and a DataTemplate to populate a MenuItem inside my Menu bar. (WPF, C#/XAML) See snipet below.
Result: The top menu item appears, when i click on it, the wrapping menu item (the one with the bound header text) appears along with the little arrow indicating the presence of children but hovering or cli...
I have a tabcontrol where the tabitem's are datatemplated. The template seems to work correctly, in that the usercontrol I want to show in the tabitem is showing correctly.
What I am not sure of is how to get a "x" to show up in the tabitem so I can close each tab, since they are dynamically generated through a template.
Being fairly ...
I am using DataTemplates to render items in an ItemsControl. I want to show a tooltip for each item. If I use a binding such as ToolTip="{Binding MyToolTip,Mode=OneWay}", WPF gets the tooltip once at the beginning and does not update the tooltip when it is opened.
My items implement INotifyPropertyChanged, so in principle I could genera...
I defined a DataTemplate for the header of my GroupBoxes:
<Style x:Key="GroupBoxHeaderStyle" TargetType="{x:Type GroupBox}">
<Setter Property="Foreground" Value="White"></Setter>
<Setter Property="HeaderTemplate">
<Setter.Value>
<DataTemplate>
<Tex...
How do I derive a new class from DataTemplate and then use it in place of DataTemplate?
For example, in C#:
public class DerivedDataTemplate : DataTemplate
{
}
Then in XAML:
<local: DerivedDataTemplate DataType="{x:Type local:SomeType}">
<Grid>
... UI here ...
</Grid>
</local:DerivedDataTemplate>
When I try to use ...
I have been searching around to find the best option of doing this.
Basically, I want to do two way databinding of multiple controls (textbox, dropdownlist, checkbox, etc) to a single instance of custom class/entity, ie: Person.
It seems, the (only?) way to do this is using an like so:
<asp:FormView ID="FormView1" runat="server" Data...
Is there a short way to make a FooterTemplate (in a GridView) always visible, even when DataSource is empty?
...
I'm using a TabControl as my main workspace in an application, and I'd like to add a "Window" menu item that lists the headers of open tabs. The active (i.e. - focused) tab should be checked.
I've tried using an ItemsTemplate as follows:
<MenuItem Header="_Window" ItemsSource="{Binding ElementName=ux_workspace, Path=Items}...
Hi, I hope someone out there can help me.
I have created a dropdown treeview using a treeview in a popup and displaying the selected item in a content control.
<Grid Background="White" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width=...
I have this simple XAML example:
<Window x:Class="DynTemplateTest.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Window.Resources>
<DataTemplate x:Key="ItemTemplate">
<ItemsCo...
I am trying to successfully TwoWay bind an ObservableCollection to TextBoxes in a DataTemplate. I can get the data to display properly, but I am unable to change the list data through the UI. I have a Model class named 'model' which contains an ObservableCollection named 'List'. The class implements the INotifyPropertyChanged interface. ...
When I bind Menu Items with an ObservableCollection, only the "inner" area of the MenuItem is clickable:
In my View I have this menu:
<Menu>
<MenuItem
Header="Options" ItemsSource="{Binding ManageMenuPageItemViewModels}"
ItemTemplate="{StaticResource MainMenuTemplate}"/>
</Menu>
Then I bind it with this D...
I'm building a Silverlight control and I'm trying to set up bindings for the Header and Body ContentControls through their respective DataTemplates. I'm not sure why, but this does not work (silently fails). My only guess is that it is because the DataTemplates are StaticResources. Can anyone offer advice? The control has the followi...