datatemplate

Making a grid in a ListView ItemTemplate fill

て烟熏妆下的殇ゞ 提交于 2019-12-05 04:10:50
I have a ListView which has a data template based on a grid. The xaml is as follows: <ListView ItemsSource="{Binding SomeItemSource}" HorizontalAlignment="Stretch" Height="281"> <ListView.ItemTemplate> <DataTemplate> <Grid HorizontalAlignment="Stretch" Margin="3" Width="Auto"> <Grid.RowDefinitions> <RowDefinition></RowDefinition> <RowDefinition></RowDefinition> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="70"></ColumnDefinition> <ColumnDefinition Width="*"></ColumnDefinition> </Grid.ColumnDefinitions> <!-- Grid content here --> <TextBlock Text="SomeTextbox" Margin=

Design time data for datatemplate in xaml

旧城冷巷雨未停 提交于 2019-12-05 00:14:43
This may be a stupid question, but is it possible to define some sample data as DataContext in order to see my DataTemplate in DesignView? At the moment I always have to run my application to see whether my changes are working. E.g. with the following code DesignView just shows an empty list box: <ListBox x:Name="standardLayoutListBox" ItemsSource="{Binding myListboxItems}"> <ListBox.ItemTemplate> <DataTemplate> <Grid> <Grid.RowDefinitions> <RowDefinition /> <RowDefinition /> </Grid.RowDefinitions> <Label Grid.Column="0" Content="{Binding text1}" /> <Label Grid.Column="1" Content="{Binding

DataTemplates in WPF

巧了我就是萌 提交于 2019-12-04 22:42:51
问题 I have a general question about data templates in WPF. Let's say I have an abstract class called "Question," and various subclasses like "MathQuestion," "GeographyQuestion," etc. In some contexts, rendering the questions as a "Question" using the "Question" data template is good enough, but let's say that I have a list of random Question objects of varying subclasses that I want to display in-turn. I want to display them to the user using their specific data templates rather than their

.NET 4 control default templates without Blend

血红的双手。 提交于 2019-12-04 22:09:09
问题 How do people find the default templates of .NET controls when they can't use Expression Blend? So far, when I needed the templates for WPF controls I went to the WPF project page on Codeplex, browsed the source code and usually found the default templates in "Generic.xaml" files. But now I am looking for the default template for the "Frame" control. I can't find it on Codeplex, and I don't see it either in the .NET framework source provided by MS (XAML files are not provided, only .cs files)

WPF - Databind to a StackPanel using DataTemplates

天涯浪子 提交于 2019-12-04 18:37:38
问题 I've modified my question since it has changed focus when trying things out. I narrowed the problem down to the following... I try to bind the selected Item of a TreeView to a StackPanel (or some other container that can hold User Controls). This container will then display a UserControl, depending on the type of the selected item. Here is the xaml of the StackPanel (both treeview and stackpanel are in the same window ==> different grid column) <StackPanel Grid.Column="2" MinWidth="500"

Why is this WPF ComboBox not showing the selected value?

天大地大妈咪最大 提交于 2019-12-04 18:30:53
<CombobBox x:Name="cbo" Style="{StaticResource ComboStyle1}" DisplayMemberPath="NAME" SelectedItem="{Binding Path=NAME}" SelectedIndex="1"> <ComboBox.ItemTemplate> <DataTemplate> <Grid> <TextBlock Text="{Binding Path=NAME}"/> </Grid> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox> In the Window OnLoaded event, I wrote the code to set the ItemsSource : cbo.ItemsSource = ser.GetCity().DefaultView; While loading the window I can see that the initially the the first item is loading but at the same time it clears the displayed item. I am stuck in this scenario and any help is appreciated.

How to bind to parent DataTemplate from within an ItemsControl.ItemTemplate

点点圈 提交于 2019-12-04 18:07:29
I have a container type control which contains a number of items. The container control has a DataTemplate defined which also contains a ItemsControl with a DataTemplate for the item. The items however need to bind to something from the container control. A simplified example is given below: <DataTemplate DataType="{x:Type ContainerType}"> <!-- Display of the container stuff--> <ItemsControl ItemsSource="{Binding Items, Mode=OneWay}"> <ItemsControl.ItemTemplate> <DataTemplate DataType="{x:Type Item}"> <!-- Display of the item stuff --> <ComboBox Text="Choose a container-level option..."

DataGrid ColumnWidth Property ignored in DataTemplate for row details

核能气质少年 提交于 2019-12-04 15:38:20
This is the UserControl that displays the details from my application and as you can see the ColumnWidth Property is explicit set to * . I also tried to set the Width property from the DataGridTextColumn . <UserControl x:Class="WpfUserInterface.MyDetailsView" 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-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d" Height="185" d:DesignWidth="480"> <Grid> <DataGrid ColumnWidth="*"

Data bindings in Data Template not working

可紊 提交于 2019-12-04 13:45:20
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 Control <Grid> <Border Style="{StaticResource FilterPanelBorderStyle}"> <StackPanel Orientation=

WPF DataTemplate property set at Content

瘦欲@ 提交于 2019-12-04 13:30:11
问题 New to WPF and have Tabs and in each tab the content is presented in a curved corner panel/window/whateveryouwannacallit. I wasn't sure how to do this ( Style, ControlTemplate ) but decided to go the DataTemplate way. So now I have this DataTemplate: <DataTemplate x:Key="TabContentPresenter" > <Border Margin="10" BorderBrush="{StaticResource DarkColorBrush}" CornerRadius="8" BorderThickness="2" Grid.Row="0" Padding="5" Background="{TemplateBinding Background}"> <ContentPresenter Content="