datatemplate

WPF Heirachical DataTemplate in TreeView

醉酒当歌 提交于 2021-02-16 15:18:30
问题 I am trying to get my head around Heirarchical DataTemplates and TreeViews in WPF and am having some trouble. I have created an app with only a TreeView on the form as below and defined HierarchicalDataTemplate's for both a Directory object and a File object I then Bind the TreeView to the Directories property (ObservableCollection) of my model. <Grid> <Grid.Resources> <HierarchicalDataTemplate DataType="{x:Type local:Directory}" ItemsSource ="{Binding Directories}"> <TextBlock Text="{Binding

Binding textbox in ListView's header datatemplate to a filter property

喜你入骨 提交于 2021-02-10 18:53:54
问题 I am creating a customized listview header that has the header text but also has a textbox that you can enter to filter the content of that column. My code currently looks like this: <UserControl.Resources> <DataTemplate x:Key="myHeaderTemplate"> <StackPanel> <TextBlock FontSize="14" Foreground="DarkBlue" Margin="20,4" Text="{Binding}" /> <TextBox Text="" Margin="4,2" /> </StackPanel> </DataTemplate> </UserControl.Resources> which is the definition for the header datatemplate containing the

Binding textbox in ListView's header datatemplate to a filter property

末鹿安然 提交于 2021-02-10 18:53:24
问题 I am creating a customized listview header that has the header text but also has a textbox that you can enter to filter the content of that column. My code currently looks like this: <UserControl.Resources> <DataTemplate x:Key="myHeaderTemplate"> <StackPanel> <TextBlock FontSize="14" Foreground="DarkBlue" Margin="20,4" Text="{Binding}" /> <TextBox Text="" Margin="4,2" /> </StackPanel> </DataTemplate> </UserControl.Resources> which is the definition for the header datatemplate containing the

Bind properties to elements inside a Listview DataTemplate

空扰寡人 提交于 2021-02-10 06:22:06
问题 I can't get databinding to work within a DataTemplate in Xamarin forms. I can get it to work with the ListView (i.e. binding the RowHeight ), but once in the DataTemplate , setting things to a property of my ViewModel has no affect. In the below example, if I set the ColumnDefinition.Width to a property, it is completely ignored, but setting it to a hard value works fine. I have put in a label to see what the property value is and it turns out blank when inside the Datatemplate , and I have

recursive menu item with default template and itemTemplate

核能气质少年 提交于 2021-02-07 12:54:43
问题 I have a WPF Control template for the MenuItem type: <Style TargetType="{x:Type MenuItem}"> <Setter Property="Background" Value="Transparent" /> <Setter Property="Cursor" Value="Hand" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type MenuItem}"> <Border Background="{TemplateBinding Background}"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="*" /> <ColumnDefinition Width="Auto" /> </Grid.ColumnDefinitions>

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

Creating menuitems from list with bindings results in blank items

南楼画角 提交于 2021-01-29 20:58:54
问题 I have a Menuitem which is supposed to show a list of quantities as children which show a list of the units defined for this quantity as children. The list of quantities is set in code-behind to the ItemsSource of the MenuItem. <MenuItem Header="common.unitsystem" Name="mnuItemUnits"> <MenuItem.Resources> <DataTemplate DataType="{x:Type guidev:Measurement}"> <StackPanel> <TextBlock Text="Measurement"/> <TextBlock Text="{Binding Name}"/> </StackPanel> </DataTemplate> <HierarchicalDataTemplate

How to use the same DataTemplate and bind to outside dynamic properties

非 Y 不嫁゛ 提交于 2021-01-29 08:02:05
问题 I successfully set up my datagrid to support filtering . All I did was create a DataTemplate that contained a toggle button and a popup window with a TextBox serving as the filter search box. I created two for each column (total of 2) this way in the <DataGrid.Resources></DataGrid.Resources> Here is my xaml: <DataTemplate x:Key="FooHeaderTemplate"> <Grid Margin="0, 0, -5, 0"> <Grid.ColumnDefinitions> <ColumnDefinition/> <ColumnDefinition Width="Auto"/> </Grid.ColumnDefinitions>

Cannot find Trigger target… the target must appear before

泄露秘密 提交于 2021-01-28 21:44:01
问题 I'm getting this warning: Cannot find the Trigger target ' ErrandPropertiesGroupBox '. (The target must appear before any Setters, Triggers, or Conditions that use it.) Here's the XAML: <UserControl.Resources> <ResourceDictionary> <ObjectDataProvider x:Key="ErrandData" /> <DataTemplate x:Key="GroupTemplate"> <GroupBox> <GroupBox.Header> <WrapPanel> <Label Content="Group #" /> <Label Content="{Binding Path=df_groupOrder}" /> </WrapPanel> </GroupBox.Header> <ListBox ItemsSource="{Binding Path

Cannot find Trigger target… the target must appear before

最后都变了- 提交于 2021-01-28 21:01:54
问题 I'm getting this warning: Cannot find the Trigger target ' ErrandPropertiesGroupBox '. (The target must appear before any Setters, Triggers, or Conditions that use it.) Here's the XAML: <UserControl.Resources> <ResourceDictionary> <ObjectDataProvider x:Key="ErrandData" /> <DataTemplate x:Key="GroupTemplate"> <GroupBox> <GroupBox.Header> <WrapPanel> <Label Content="Group #" /> <Label Content="{Binding Path=df_groupOrder}" /> </WrapPanel> </GroupBox.Header> <ListBox ItemsSource="{Binding Path