datatemplate

Data bindings in Data Template not working

泄露秘密 提交于 2019-12-21 19:55:43
问题 I have UserControl to do filtering for several presentations, which in turn has a ContentControl. The content are the individual filtering controls that vary among the presentations. The scheme works as intended visually, but the data bindings do not. There are no data binding errors in output. The DataContext is from a view model call PimMasterVm, which otherwise seems correctly wired (ie, the status of 5 avalable people, etc) Can someone help me trouble shoot this? Cheers, Berryl Filtering

Contentpresenter with type based datatemplate selection and binding

别来无恙 提交于 2019-12-21 19:28:11
问题 I have an ItemsControl that binds to a list of items. These items have a name and value property. The value property is of type Object to allow different datatypes to be used. To display the value property correctly I use a ContentPresenter with a datatemplate for every datatype I might use. <ItemsControl ItemsSource="{Binding Items}"> <ItemsControl.ItemTemplate> <DataTemplate> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"/> <ColumnDefinition Width="Auto" /> <ColumnDefinition

How to set the DataContext for a View created in DataTemplate from ViewModel

半世苍凉 提交于 2019-12-21 17:49:07
问题 There are questions on this already, but they don't answer my question. For example: <ContentControl.Resources> <DataTemplate DataType="{x:Type Databinding:RedScreenViewModel}" > <Databinding:RedScreen DataContext="{Binding}"/> </DataTemplate> <DataTemplate DataType="{x:Type Databinding:BlueScreenViewModel}"> <Databinding:BlueScreen DataContext="{Binding}" /> </DataTemplate> </ContentControl.Resources> As you can see I am attempting to set the DataContext for the created View hoping that it

Adding Visual States to a Data Template in Windows 8

不想你离开。 提交于 2019-12-21 17:31:40
问题 I am trying to add a Mouse Over effect to my Windows 8 application. Specifically I'm trying to add it to DataTemplates bound to a GridView. However, Currently, nothing is happening, I've tried to follow the Microsoft tutorials but most of those are either out of date or for different versions of XAML. My code looks like this: <DataTemplate x:Key="GameTileTemplate"> <Grid x:Name="grid" Width="173" Height="173" RenderTransformOrigin="0.5,0.5" > <Grid.Clip> <RectangleGeometry Rect="0,0,173,173"/

How to define a DataTemplate in code?

和自甴很熟 提交于 2019-12-21 07:34:12
问题 How can I create a DataTemplate in code (using C#) and then add a control to that DataTemplate ? <data:DataGrid.RowDetailsTemplate> <DataTemplate> <Border> <Border Margin="10" Padding="10" BorderBrush="SteelBlue" BorderThickness="3" CornerRadius="5"> <TextBlock Text="{Binding Description}" TextWrapping="Wrap" FontSize="10"> </TextBlock> </Border> </Border> </DataTemplate> </data:DataGrid.RowDetailsTemplate> I am using Sivlerlight. 回答1: As far as I know, the only way to create a DataTemplate

How to get a parent value in multibinding

寵の児 提交于 2019-12-21 07:15:35
问题 I'm using dataTemplate . This is the template: <ItemsControl ItemsSource="{Binding RAM.Partitions}"> <ItemsControl.ItemTemplate> <DataTemplate> <Grid> <TextBlock Text="{Binding Position, StringFormat={}{0}k}"/> <Grid Grid.Column="1"> <Border> <Border.Height> <MultiBinding Converter="{StaticResource MultiplyConverter}"> <Binding ElementName="LayoutRoot" Path="ActualHeight"/> <Binding Path="Size" /> <Binding Path="RAM.Size" /> </MultiBinding> </Border.Height> </Border> </Grid> </Grid> <

Name does not exist in the namespace

泪湿孤枕 提交于 2019-12-21 05:25:09
问题 I am working on a simple UWP project using data template binding in VS 2015. When ever I try to specify the type for the Datatemplate I get an error. XAML: <Page x:Name="RootPage" x:Class="Adaptive_News_Layout.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:Adaptive_News_Layout" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup

UWP DataTemplates for multiple item types in ListView

廉价感情. 提交于 2019-12-21 04:33:32
问题 How would I go about implementing this? Let's say this is my model: public interface IAnimal { string Name { get; } } public class Fish : IAnimal { public string Name { get; set; } public int ScalesCount { get; set; } } public class Dog : IAnimal { public string Name { get; set; } public string CollarManufacturerName { get; set; } } public class ViewModel { public ObservableCollection<IAnimal> Animals { get; set; } public ViewModel() { this.Animals = new ObservableCollection<IAnimal>(); this

Enable a TabItem via Binding

核能气质少年 提交于 2019-12-21 03:55:10
问题 I want to use MVVM in an application where the different pages are TabItems. For this I use an observable collection of my view models (Items) and bind it to the tabcontrols ItemSource. For each view model, I created an individual data template to render the correct view like this: <DataTemplate DataType="{x:Type baseVm:AViewModel}"> <baseVw:AView /> </DataTemplate> To display the correct name in the tab's header I created another data template to be applied to each of the tab control's

XAML: Binding a property in a DataTemplate

限于喜欢 提交于 2019-12-20 13:18:12
问题 I'm fairly new to XAML but enjoying learning it. The thing I'm really struggling with is binding a property to an element in a DataTemplate . I have created a simple WPF example to, (hopefully,) explain my problem. I this example I am trying to bind the Visibility property of a CheckBox in a DataTemplate to a Property in my viewmodel. (Using this scenario purely for learning/demo.) I have a simple DataModel named Item , but is of little relevance in this example. class Item :