contentcontrol

multiple binding to IsEnable

邮差的信 提交于 2019-12-04 02:39:48
I need to bind a TextBox that meets two criteria: IsEnabled if Text.Length > 0 IsEnabled if user.IsEnabled Where user.IsEnabled is pulled from a data source. I was wondering if anyone had a easy method for doing this. Here is the XAML: <ContentControl IsEnabled="{Binding Path=Enabled, Source={StaticResource UserInfo}}"> <TextBox DataContext="{DynamicResource UserInfo}" Text="{Binding FirstName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsEnabled="{Binding Path=Text, RelativeSource={RelativeSource Self}, Converter={StaticResource LengthToBool}}"/> </ContentControl> Since you only need

Unable to set ContentTemplate via DataTrigger

荒凉一梦 提交于 2019-12-03 13:33:51
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 IsChecked="{Binding BoolProperty, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type src

ContentControl with DataTemplateSelector - help needed

不羁岁月 提交于 2019-11-30 20:32:09
I got an enoying problem... Maybe someone can (please!) help. I am using a model that has and enumeration of types and a property that should hold UI models for each selected type from enumeration: Let's define them like: class ViewModel { Types selectedType{get;set;} UiModelBase editedModel{get;set;} } I want to have a content control that use datatemplateselector to change his view each time I change the selectedType. <ListBox x:Name="RuleTypeList" ItemsSource="{Binding Source={StaticResource Types}}" SelectedItem="{Binding Path=selectedType}"/> <!--Content control--> <ContentControl

ContentControl with DataTemplateSelector - help needed

心已入冬 提交于 2019-11-30 05:01:32
问题 I got an enoying problem... Maybe someone can (please!) help. I am using a model that has and enumeration of types and a property that should hold UI models for each selected type from enumeration: Let's define them like: class ViewModel { Types selectedType{get;set;} UiModelBase editedModel{get;set;} } I want to have a content control that use datatemplateselector to change his view each time I change the selectedType. <ListBox x:Name="RuleTypeList" ItemsSource="{Binding Source=

How to Bind To Data within a Datatemplate of a ContentControl

梦想的初衷 提交于 2019-11-30 03:21:30
I have the following simplified Example: <Window x:Class="TemplateBinding.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <Window.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="pack://application:,,,/TemplateBinding;component/PersonTemplate.xaml" /> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Window.Resources> <Grid> <ContentControl ContentTemplate="{StaticResource PersonTemplate}" /> </Grid>

How to Bind To Data within a Datatemplate of a ContentControl

非 Y 不嫁゛ 提交于 2019-11-29 00:37:49
问题 I have the following simplified Example: <Window x:Class="TemplateBinding.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <Window.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="pack://application:,,,/TemplateBinding;component/PersonTemplate.xaml" /> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> <

Display a default DataTemplate in a ContentControl when its content is null or empty?

▼魔方 西西 提交于 2019-11-28 17:12:16
I would think this is possible, but the obvious way isn't working. Currently, I'm doing this: <ContentControl Content="{Binding HurfView.EditedPart}"> <ContentControl.Resources> <Style TargetType="ContentControl" x:Key="emptytemplate"> <Style.Triggers> <DataTrigger Binding="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=Content}" Value="{x:Null}"> <Setter Property="ContentControl.Template"> <Setter.Value> <ControlTemplate> <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> <TextBlock>EMPTY!</TextBlock> </Grid> </ControlTemplate> </Setter.Value> </Setter> <

Explicitly refresh DataTemplate from a DataTemplateSelector?

血红的双手。 提交于 2019-11-28 10:49:24
I set up a ContentControl.DataTemplateSelector to my desired one. I want that according to a command or whatever, call the ContentControl to reselect the template from the selector by either xaml or code. Thank I'm not aware of any (non-kludgy) way to do this: the DataTemplateSelector is called when WPF needs to select the template, and that's a one-off decision as far as WPF is concerned. (You can kludge it by making WPF think the content has changed, e.g. by setting the content to null and then back again -- I think that would work but haven't tested it -- but this is pretty ugly!) If there

How do I load controls in different ContentControls of a Shell using CaliburnMicro

百般思念 提交于 2019-11-28 00:48:29
问题 By default when you use "ActivateItem(new Control());" your control is loaded into a ContentControl which with the name ActiveItem, fro example. . If I have multiple content controls on my page how would I load controls into them whilst retaining the ability to use the default functionality of being able to load controls into the the active item control. for example I want to have a login control to be loaded into the Login ContentControl, and when a user successfully login I want a new

Display a default DataTemplate in a ContentControl when its content is null or empty?

我的未来我决定 提交于 2019-11-27 20:03:57
问题 I would think this is possible, but the obvious way isn't working. Currently, I'm doing this: <ContentControl Content="{Binding HurfView.EditedPart}"> <ContentControl.Resources> <Style TargetType="ContentControl" x:Key="emptytemplate"> <Style.Triggers> <DataTrigger Binding="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=Content}" Value="{x:Null}"> <Setter Property="ContentControl.Template"> <Setter.Value> <ControlTemplate> <Grid HorizontalAlignment="Stretch" VerticalAlignment=