datatemplateselector

DataTemplate Selector after DataContext Set

限于喜欢 提交于 2020-07-10 03:17:38
问题 I have a DataGrid with 2 columns. Based on the first column which is bound to ParameterDataType I want to load the appropriate template in the second column. Problem with this code is before the DataGrid has been loaded, the template selector is executing as a result the item is null. Is there a way to execute the Template Selector after the ControlTemplate's DataContext is set. Please help. Here is my xaml: <uwpControls:DataGrid Grid.Row="4" ItemsSource="{x:Bind ViewModel.ServiceMethodsData

How to trigger datatemplate selector in Windows Phone?

冷暖自知 提交于 2020-01-17 02:22:27
问题 I have a property and depending upon it's state (say A and B) I either show a usercontrol of animation or a image. Now, if the property changes, I want to trigger the datatemplate selector again. On searching, I found that in WPF I could have used DataTemplate.Trigger but it's not available in WP. So, my question is Is their a way to trigger datatemplate selector so when property changes from state A to B, then appropriate usercontrol gets selected. If yes, then please give some example how

DataTemplate for a DataType - how to override this DataTemplate in a particular ListBox?

荒凉一梦 提交于 2020-01-02 06:58:31
问题 I have created several DataTemplates for some of the DataTypes in my pet project. These data templates are really cool as they work like magic, magically transforming the look of the instances of the data types whenever and wherever they show up in the UI. Now I want to be able to change the DataTemplate for these DataTypes in one particular ListBox. Does this mean I have to stop relying on WPF automatically applying the data template to the data types and assign a x:Key to the DataTemplates

UWP: DataTemplateSelector and SelectedItem

与世无争的帅哥 提交于 2019-12-29 06:29:14
问题 How can I change the DataTemplate for the SelectedItem of ListView in UWP project? I'm trying to use the DataTemplateSelector but the problem is that SelectTemplateCore is called only one time. This what I have tried: MyTemplateSelector class public class MyTemplateSelector : DataTemplateSelector { public DataTemplate DefaultTemplate { get; set; } public DataTemplate SelectedItemTemplate { get; set; } protected override DataTemplate SelectTemplateCore(object item, DependencyObject container)

ContentControl does not change the content - function never called

落爺英雄遲暮 提交于 2019-12-25 00:42:49
问题 I want to change my content off an AppBar dynamicly whith this code: <Page.Resources> <local:AppBarSelector x:Key="myAppBarSelector"/> </Page.Resources> <Page.BottomAppBar> <AppBar> <ContentControl Content="{Binding SelectedItem, ElementName=listBox}" ContentTemplateSelector="{StaticResource myAppBarSelector}"> <ContentControl.Resources> <DataTemplate x:Key="1"> <TextBlock Text="Hallo Welt 1" Foreground="White" /> </DataTemplate> <DataTemplate x:Key="2"> <TextBlock Text="Hallo Welt 2"

Determining value of ContentTempateSelector based on two properties

爷,独闯天下 提交于 2019-12-24 14:05:59
问题 I am unable to change the contents of the ContentTemplateSelector . Based on the two properties Eligibility and ListOfThings , the text block is updated and it is achieved by multibinding. However, the multi binding approach could not be applied for the template selector. Here is my code : XAML : <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <ContentControl Grid.Column="0" Style="{StaticResource StatusIconStyle}"

Why can't a DataTemplate bind to an interface when that DataTemplate was explicitly returned from a DataTemplateSelector?

牧云@^-^@ 提交于 2019-12-22 04:57:23
问题 I've created a DataTemplateSelector which is initialized with a collection of known interfaces. If an item passed into the selector implements one of those interfaces, the associated data template is returned. First, here's the ICategory interface in question... public interface ICategory { ICategory ParentCategory { get; set; } string Name { get; set; } ICategoryCollection Subcategories { get; } } Here's the DataTemplateSelector which matches based on a base class or interface rather than

How do I use a ItemTemplateSelector together with a HeaderTemplate in a WPF ListView?

≯℡__Kan透↙ 提交于 2019-12-19 05:59:56
问题 Suppose the following XAML defined window: <Window x:Class="LayoutTests.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:LayoutTests" Title="Window1"> <Window.Resources> <XmlDataProvider x:Key="XmlData" IsInitialLoadEnabled="True"> <x:XData> <Items xmlns=""> <Item text="Item 1" type="A" /> <Item text="Item 2" type="B" /> <Item text="Item 3" type="A" /> </Items> </x:XData> <

Force DataTemplateCell with CellTemplateSelector in WPF DataGrid Autogenerated columns

戏子无情 提交于 2019-12-13 04:20:37
问题 I have a data grid to which I bind a DataTable. I don't know what rows or columns will be in the data table so I set the AutogenerateColumns property of the data grid to true. The only thing I do know for certain is that every cell in the data table will be of type Field and the Field class has a enum property called Type. <DataGrid x:Name="dg" AutoGenerateColumns="True" ItemsSource="{Binding Path=Fields}" AutoGeneratingColumn="dg_AutoGeneratingColumn"> </DataGrid> What I want to do is to