datatemplate

Is loading the controls from template by traversing through the VisualTree a right way?

风格不统一 提交于 2019-12-12 03:36:58
问题 I have a custom control which has it's template defined and the template contains below code: <FlipView Grid.Row="3" Grid.ColumnSpan="2" x:Name="FlipView1" BorderBrush="Black" ItemsSource="{Binding ItemsCollection, RelativeSource={RelativeSource TemplatedParent}}"> <FlipView.ItemTemplate> <DataTemplate> <ScrollViewer> <Grid> <local:UserControlA x:Name="PART_UserControlA"/> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="100" /> <ColumnDefinition /> </Grid.ColumnDefinitions> <local

Treeview with multiple columns

微笑、不失礼 提交于 2019-12-12 03:35:39
问题 I am trying to create a treeview in WPF with multiple columns. I am well aware, that there are really numerous questions regarding this subject. However they seem to take a different approach when binding the data. Everybody seems to set the itemssource, as where I fill the treeview.items in de code behind. That is also the reason I am not sure whether to use ItemTemplate / HierarchicalDataTemplate or the correct way to accomplish it. (I have the feeling that this should be an easy step.) The

Is it possible to define a TreeView hierarchical view template for a 'plain' collection?

偶尔善良 提交于 2019-12-12 03:16:53
问题 I have my model classes that look like this: class Base { public string Name { get; set; } } class Item : Base { ... } class Group : Base { public List<Base> GroupItems { get; private set; } } Then, I have a view model with an Items collection, that I fill up like shown in the FillUp() method below: class ViewModel : INotifyPropertyChanged { public ObservableCollection<Base> Items { get; set; } private void FillUp() { Item item1 = new Item { Name = "Item1" }; Item item2 = new Item { Name =

How to reference a static resource from within a datatemplate

[亡魂溺海] 提交于 2019-12-12 03:05:25
问题 I have the following problem: <DataTemplate x:Key="OrganisationsItemTemplate"> <StackPanel VerticalAlignment="Top" Margin="5,0,0,0"> <Button Command="{Binding Path=DataContext.LoadSpacesCommand, ElementName=OrganisationList}" CommandParameter="{Binding}" Padding="-5,0,-5,-5" Margin="-7,-12,-7,-7" Height="auto" BorderThickness="0" HorizontalAlignment="Left" VerticalAlignment="Stretch" HorizontalContentAlignment="Left" UseLayoutRounding="True" FontSize="0.01"> <Grid Margin="0,0,5,0"> <Grid

DataTemplate for Listbox containing lists as items doesn't get displayed

て烟熏妆下的殇ゞ 提交于 2019-12-12 02:58:39
问题 I have the following data template for a list box items: <DataTemplate x:Key="substanceListShower"> <ListBox ItemsSource="{Binding Items}"> <ItemsPanelTemplate> <StackPanel Orientation="Horizontal"/> </ItemsPanelTemplate> </ListBox> </DataTemplate> And then I apply the item template like this: ReactantInterfacesListBox.ItemTemplate = (DataTemplate)FindResource("substanceListShower"); But in the list for the items i get a ToString() return: System.Windows.Controls.ItemsPanelTemplate Any help

Load a listbox with two textblock from a database with LINQ windows phone

时光毁灭记忆、已成空白 提交于 2019-12-12 02:33:56
问题 I am trying to load a listbox with two textblock from a database with LINQ in windows phone 7.1. My problem is that data does not appear in the textblock. Maybe the problem is in the xaml code, but I don´t know. This is the xaml code: <controls:Pivot Title="CEBADEROS"> <controls:PivotItem Header="Entradas"> <ListBox x:Name="EntradasList" Margin="0,0,-12,0"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Margin="0,0,0,17"> <TextBlock Text="{Binding Fecha_entrada}" TextWrapping="NoWrap"

Setting Window.Content to ViewModel - simple data template not working

↘锁芯ラ 提交于 2019-12-12 02:26:32
问题 Trying to get my head around MVVM, and getting a simple window to render its viewmodel as a view via data templating. in App.xaml: <Application.Resources> <DataTemplate DataType="{x:Type vm:TestViewModel}"> <vw:TestView /> </DataTemplate> </Application.Resources> View definition: <UserControl x:Class="MyNamespace.TestView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup

UserControl as Content for HeaderedContentControl.HeaderTemplate

会有一股神秘感。 提交于 2019-12-12 02:14:14
问题 I have a UserControl that I have successfully been using as a header for presentations that involve a list which can be headered, using the xaml below: <DockPanel > <uc:ListSubjectHeader Subject="{Binding DisplayName}" AddNewItemCommand="{Binding AddCommand}" ImageSource="..." /> <!-- other controls --> </DockPanel> I would like to use this same control in another presentation where it would be the content for the header in a HeaderedContentControl, and came up with this xaml to do that:

Why is the SelectTemplate Method run 2 times in debug mode?

假装没事ソ 提交于 2019-12-12 01:43:48
问题 debuging this class the SelectTemplate Method is run 2 times, but why? The first time the item is always null. public class PersonDataTemplateSelector : DataTemplateSelector { public override DataTemplate SelectTemplate(object item,DependencyObject container) { if (item is Person) { Person person = item as Person; Window window = Application.Current.MainWindow; if (System.ComponentModel.DesignerProperties.GetIsInDesignMode( window)) return null; if (person.Gender == "male") return window

DataTemplate DataType usage WPF

余生颓废 提交于 2019-12-12 01:18:27
问题 I had been setting the DataContext for UserControls like so: <uc:DepartmentListingView DataContext="{Binding ., Mode=TwoWay}" /> Based on a sample project by Josh Smith I am trying to accomplish the same thing with a DataTemplate and DataType: <!-- Template applies a DepartmentListingView to an instance of the DepartmentSelectionViewModel class. --> <DataTemplate DataType="{x:Type model:DepartmentSelectionViewModel}"> <uc:DepartmentListingView /> </DataTemplate> This works well, but of course