contentcontrol

DataTemplate does not refresh after switching to an object of same DataType

青春壹個敷衍的年華 提交于 2021-02-07 09:10:47
问题 I have following ControlTemplate : <ContentControl Content="{Binding ContentViewModel}"> <ContentControl.Resources> <DataTemplate DataType="{x:Type viewModel:FilledContentViewModel}"> <usercontrols:FilledMainWindow x:Name="MainContent" /> </DataTemplate> <DataTemplate DataType="{x:Type viewModel:EmptyContentViewModel}"> <!-- todo: Something like a StartPage here --> </DataTemplate> </ContentControl.Resources> </ContentControl> This works great until the view model tries to change the

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 conditionally insert a Checkbox in a list item of a customized ListView?

痞子三分冷 提交于 2020-02-07 23:49:05
问题 I try to make a customized ListView which fills each list item with some stuff and an initial Checkbox if desired. Currently no Checkbox is displayed so I guess my code of the ContentControl stuff is somehow erroneous. <ListView xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <ListView.View> <GridView> <GridViewColumn> <GridViewColumn.CellTemplate> <DataTemplate> <!-- Each list item: [Checkbox] Label --> <StackPanel

Interaction Triggers Embedded in ContentControl

半腔热情 提交于 2020-02-03 09:02:57
问题 So to keep the question simple what I need for example is to use something like this dozens of times; <Rectangle> <i:Interaction.Triggers> <i:EventTrigger EventName="MouseLeftButtonDown"> <ei:ChangePropertyAction TargetName="AnotherObjectOnTheView" PropertyName="Visibility" Value="Visible" /> </i:EventTrigger> </i:Interaction.Triggers> </Rectangle> Except obviously I don't want to paste that dozens of times everywhere I need it. So I tried to plop them in a ContentControl , something like

Interaction Triggers Embedded in ContentControl

大兔子大兔子 提交于 2020-02-03 09:01:07
问题 So to keep the question simple what I need for example is to use something like this dozens of times; <Rectangle> <i:Interaction.Triggers> <i:EventTrigger EventName="MouseLeftButtonDown"> <ei:ChangePropertyAction TargetName="AnotherObjectOnTheView" PropertyName="Visibility" Value="Visible" /> </i:EventTrigger> </i:Interaction.Triggers> </Rectangle> Except obviously I don't want to paste that dozens of times everywhere I need it. So I tried to plop them in a ContentControl , something like

Unable to set ContentTemplate via DataTrigger

自古美人都是妖i 提交于 2020-01-01 05:18:10
问题 I want the ContentTemplate to vary according to the value in the DataTrigger . And yes, I considered using a DataTemplateSelector , but now I need a DataTrigger or better said a MultiDataTrigger . Please take a look at the following sample app, the DataTemplate doesn't change: <Window x:Class="Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:src="clr-namespace:WpfApplication1"> <StackPanel> <CheckBox

Binding properties through DataTemplates and ContentControl

故事扮演 提交于 2019-12-29 08:26:06
问题 I liked this answer, and it almost fit me. But, how can I achieve this if my DataTemplate is in a external ResourceDictionary ? I'm using Prism and I provide the DataTemplates (for generic CRUD views) by each module, by using files like this: <ResourceDictionary ... some hidden ns here ... > <DataTemplate DataType="{x:Type model:Operation}"> <vw:OperationView /> </DataTemplate> <DataTemplate DataType="{x:Type model:Customer}"> <vw:CustomerView /> </DataTemplate> </ResourceDictionary> Then I

can I define my own panel control with asp.net usercontrols

孤街浪徒 提交于 2019-12-25 04:26:51
问题 I want something like that: <my:MyFancyPanel> <asp:Label Text="Hello"> </my:MyFancyPanel> I tried but it seems my usercontrol doesn't accept any content. 回答1: you need to make it a Templated Usercontrol 来源: https://stackoverflow.com/questions/3829728/can-i-define-my-own-panel-control-with-asp-net-usercontrols

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"

How to get ContentControl to resolve DataTemplate

▼魔方 西西 提交于 2019-12-23 14:21:51
问题 Why does this not resolve the datatemplate? <Window.Resources> <DataTemplate DataType="system:DateTime" > <Grid Background="Aqua"> <TextBlock Text="{Binding Day}"></TextBlock> </Grid> </DataTemplate> </Window.Resources> <Grid> <ContentControl Content="{x:Static system:DateTime.Now}"/> </Grid> Writing a TemplateSelector feels like an overkill. 回答1: DataType design suggests the presence of a directive x:Type like that: <DataTemplate DataType="{x:Type system:DateTime}"> <Grid Background="Aqua">