Hello
I am trying something that I think the Outlookbar isn't created for, but I've no way else to do it (that I know of so please correct me if I'm wrong). Here is the story:
The view that i am creating has a gridview with grouping. The user can click on an item and edit its value. This can be a string, int, enum and so on. So i created a edittempateselctor that selected the right template. Everything worked, but then the costumer wanted something like the outlookbar to display the values. So I created that, but my problem is that my edittemplate isn't working anymore. The selected template is null.
This is the working grid code:
this is the edittemplateselector.cs:
The resourcedictionary with the templates:
Not working code:
So when I use this last implementation the datatemplates in the Edittemplateselector returns null.
They are In the same project in the same view, I just don't get it :)
I am trying something that I think the Outlookbar isn't created for, but I've no way else to do it (that I know of so please correct me if I'm wrong). Here is the story:
The view that i am creating has a gridview with grouping. The user can click on an item and edit its value. This can be a string, int, enum and so on. So i created a edittempateselctor that selected the right template. Everything worked, but then the costumer wanted something like the outlookbar to display the values. So I created that, but my problem is that my edittemplate isn't working anymore. The selected template is null.
This is the working grid code:
<UserControl.Resources> <custom:EditTemplateSelector x:Key="EditTemplateSelector" /></UserControl.Resources><telerik:RadGridView Grid.Row="2" ItemsSource="{Binding ListCollectionView, Mode=TwoWay}" SelectionMode="Single" AutoGenerateColumns="False" CanUserDeleteRows="False" CanUserFreezeColumns="False" CanUserReorderColumns="False" CanUserInsertRows="False" RowHeight="30" ColumnWidth="200" BorderThickness="0" ShowColumnHeaders="False" ShowGroupPanel="False" RowIndicatorVisibility="Collapsed" EditTriggers="CellClick"> <telerik:RadGridView.Columns> <aucxis:GridViewDataColumn DataMemberBinding="{Binding SubID}" IsReadOnly="True"/> <aucxis:GridViewDataColumn DataMemberBinding="{Binding DataValue}" CellEditTemplateSelector="{DynamicResource EditTemplateSelector}" Width="Auto"/> </telerik:RadGridView.Columns></telerik:RadGridView>this is the edittemplateselector.cs:
public class EditTemplateSelector : DataTemplateSelector { private IMessageBoxHandler _messageBoxHandler; public DataTemplate BoolDataTemplate { get; set; } public DataTemplate FloatDataTemplate { get; set; } public DataTemplate IntDataTemplate { get; set; } public DataTemplate StringTemplate { get; set; } public DataTemplate TimeSpanTemplate { get; set; } public DataTemplate EnumDataTemplate { get; set; } public DataTemplate FlagsEnumDataTemplate { get; set; } public DataTemplate InOutDoDataTemplate { get; set; } public override DataTemplate SelectTemplate(object item, DependencyObject container) { if (_messageBoxHandler == null) _messageBoxHandler = DependencyInjection.Container.Resolve<IMessageBoxHandler>(); var dataObject = (DataObject)item; if (dataObject == null) { const string nullValue = "This item has a nullvalue and can't be edited"; if (_messageBoxHandler != null) _messageBoxHandler.Show(nullValue, "Let op!", MessageBoxButton.OK, MessageBoxImage.Warning); else MessageBox.Show(nullValue, "Let op!", MessageBoxButton.OK, MessageBoxImage.Warning); return base.SelectTemplate(null, container); } switch (dataObject.DataValue.GetType().ToString()) { //standard Types case "System.Boolean": return BoolDataTemplate; case "System.Single": return FloatDataTemplate; case "System.Int32": return IntDataTemplate; case "System.TimeSpan": return TimeSpanTemplate; case "System.String": return StringTemplate; //Enum types case "Aucxis.VAUC.Shared.Types.AlarmRequestTypes": case "Aucxis.VAUC.Shared.Types.Proxy.AutoHandProxy": case "Aucxis.VAUC.Shared.Types.Proxy.CO2InjectieStatesProxy": case "Aucxis.VAUC.Shared.Types.Proxy.GasmetingStatesProxy": case "Aucxis.VAUC.Shared.Types.Proxy.HighLowProxy": case "Aucxis.VAUC.Shared.Types.Proxy.InOutTypeProxy": case "Aucxis.VAUC.Shared.Types.Proxy.KoelStatesProxy": case "Aucxis.VAUC.Shared.Types.Proxy.N2GeneratorKeuzeProxy": case "Aucxis.VAUC.Shared.Types.Proxy.N2GeneratorMethodesProxy": case "Aucxis.VAUC.Shared.Types.Proxy.N2GeneratorStatesProxy": case "Aucxis.VAUC.Shared.Types.Proxy.N2InjectieStatesProxy": case "Aucxis.VAUC.Shared.Types.Proxy.O2InjectieStatesProxy": case "Aucxis.VAUC.Shared.Types.Proxy.OntdooiTypesProxy": case "Aucxis.VAUC.Shared.Types.Proxy.RuimteCO2InjectieStandProxy": case "Aucxis.VAUC.Shared.Types.Proxy.RuimteGasModusProxy": case "Aucxis.VAUC.Shared.Types.Proxy.RuimteKoelModusProxy": case "Aucxis.VAUC.Shared.Types.Proxy.RuimteKoelStandProxy": case "Aucxis.VAUC.Shared.Types.Proxy.RuimteN2InjectieStandProxy": case "Aucxis.VAUC.Shared.Types.Proxy.RuimteO2InjectieStandProxy": case "Aucxis.VAUC.Shared.Types.Proxy.RuimteStatussenProxy": case "Aucxis.VAUC.Shared.Types.Proxy.RuimteTypesProxy": case "Aucxis.VAUC.Shared.Types.Proxy.VentStatesProxy": case "Aucxis.VAUC.Shared.Types.Proxy.VentWinnerProxy": case "Aucxis.VAUC.Shared.Types.Proxy.VerdamperModussenProxy": case "Aucxis.VAUC.Shared.Types.Proxy.WachtrijCommandoProxy": case "Aucxis.VAUC.Shared.Types.Proxy.WachtrijItemTypesProxy": return EnumDataTemplate; //flagEnums case "Aucxis.VAUC.Shared.Types.Proxy.AlarmTypesProxy": case "Aucxis.VAUC.Shared.Types.Proxy.LogTypesProxy": return FlagsEnumDataTemplate; case "Aucxis.VAUC.Shared.Types.Proxy.InOutDOProxy": return InOutDoDataTemplate; //Custom types (not yet implemented)*/ default: const string notYetImplemented = "This type is not yet implemented. Edit will result in fail"; if (_messageBoxHandler != null) _messageBoxHandler.Show(notYetImplemented, "Let op!", MessageBoxButton.OK, MessageBoxImage.Warning); else MessageBox.Show(notYetImplemented, "Let op!", MessageBoxButton.OK, MessageBoxImage.Warning); return base.SelectTemplate(item, container); } } }The resourcedictionary with the templates:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:custom="clr-namespace:Aucxis.VAUC.GUI.Client.Common.Custom;assembly=Aucxis.VAUC.GUI.Client.Common" xmlns:aucxis="http://schemas.aucxis.com/1/wpf" xmlns:converters="clr-namespace:Aucxis.VAUC.GUI.Client.Common.Converters;assembly=Aucxis.VAUC.GUI.Client.Common" xmlns:controls="clr-namespace:Aucxis.iRAD.Controls;assembly=Aucxis.iRAD.Controls" xmlns:touchScreenKeyBoard="clr-namespace:Aucxis.iRAD.Controls.Touch.Keyboard;assembly=Aucxis.iRAD.Controls.Touch" xmlns:touch="clr-namespace:Aucxis.iRAD.Controls.Touch;assembly=Aucxis.iRAD.Controls.Touch" xmlns:views="clr-namespace:Aucxis.VAUC.GUI.Client.Common.Custom.EditTemplates.Views;assembly=Aucxis.VAUC.GUI.Client.Common" xmlns:controls2="clr-namespace:Aucxis.VAUC.GUI.Client.Common.Custom.Controls;assembly=Aucxis.VAUC.GUI.Client.Common"> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="pack://application:,,,/Aucxis.Client.WPF;component/Themes/Generic.xaml" /> <ResourceDictionary Source="pack://application:,,,/Aucxis.iRAD.Controls.Touch;component/Themes/Generic.xaml" /> <ResourceDictionary Source="pack://application:,,,/Aucxis.iRAD.Controls;component/Themes/Generic.xaml" /> </ResourceDictionary.MergedDictionaries> <aucxis:IntToDoubleConverter x:Key="IntToDoubleConverter" /> <aucxis:InverseBooleanConverter x:Key="InverseBooleanConverter" /> <converters:SingleToDoubleConverter x:Key="SingleToDoubleConverter" /> <custom:EditTemplateSelector x:Key="EditTemplateSelector"> <custom:EditTemplateSelector.BoolDataTemplate> <DataTemplate> <views:BoolView SelectedBool="{Binding DataValue, Mode=TwoWay}" IsEnabled="{Binding ReadOnly, Converter={StaticResource InverseBooleanConverter}}" custom:FocusAttacher.Focus="{Binding ReadOnly, Converter={StaticResource InverseBooleanConverter}}"/> </DataTemplate> </custom:EditTemplateSelector.BoolDataTemplate> <custom:EditTemplateSelector.IntDataTemplate> <DataTemplate> <controls:NumericUpDown x:Name="NumericUpDown" Value="{Binding DataValue, Mode=TwoWay, Converter={StaticResource IntToDoubleConverter}}" IsEnabled="{Binding ReadOnly, Converter={StaticResource InverseBooleanConverter}}" touchScreenKeyBoard:TouchScreenNumericKeyboard.TouchScreenNumericKeyboard="True" NumberDecimalDigits="0" custom:FocusAttacher.Focus="{Binding ReadOnly, Converter={StaticResource InverseBooleanConverter}}"/> </DataTemplate> </custom:EditTemplateSelector.IntDataTemplate> <custom:EditTemplateSelector.EnumDataTemplate> <DataTemplate> <views:EnumView Value="{Binding DataValue, UpdateSourceTrigger=PropertyChanged}"/> </DataTemplate> </custom:EditTemplateSelector.EnumDataTemplate> <custom:EditTemplateSelector.FlagsEnumDataTemplate> <DataTemplate> <views:FlagsEnumView Value="{Binding DataValue, UpdateSourceTrigger=PropertyChanged}"/> </DataTemplate> </custom:EditTemplateSelector.FlagsEnumDataTemplate> <custom:EditTemplateSelector.FloatDataTemplate> <DataTemplate> <controls:NumericUpDown x:Name="NumericUpDown" Value="{Binding DataValue, Mode=TwoWay, Converter={StaticResource SingleToDoubleConverter}}" IsEnabled="{Binding ReadOnly, Converter={StaticResource InverseBooleanConverter}}" touchScreenKeyBoard:TouchScreenNumericKeyboard.TouchScreenNumericKeyboard="True" NumberDecimalDigits="2" custom:FocusAttacher.Focus="{Binding ReadOnly, Converter={StaticResource InverseBooleanConverter}}"/> </DataTemplate> </custom:EditTemplateSelector.FloatDataTemplate> <custom:EditTemplateSelector.InOutDoDataTemplate> <DataTemplate> <views:InOutDOView DataContext="{Binding DataValue, UpdateSourceTrigger=PropertyChanged}"/> </DataTemplate> </custom:EditTemplateSelector.InOutDoDataTemplate> <custom:EditTemplateSelector.StringTemplate> <DataTemplate> <touch:TextBox x:Name="txtBox" Text="{Binding DataValue, Mode=TwoWay}" touchScreenKeyBoard:TouchScreenKeyboard.TouchScreenKeyboard="True" IsEnabled="{Binding ReadOnly, Converter={StaticResource InverseBooleanConverter}}" SelectAllOnFocus="True" custom:FocusAttacher.Focus="{Binding ReadOnly, Converter={StaticResource InverseBooleanConverter}}"/> </DataTemplate> </custom:EditTemplateSelector.StringTemplate> <custom:EditTemplateSelector.TimeSpanTemplate> <DataTemplate> <controls2:TimeSpanPickerTouch x:Name="TimeSpan" Value="{Binding DataValue, Mode=TwoWay}" DaysVisible="False" HorizontalAlignment="Left" VerticalAlignment="Top" IsEnabled="{Binding ReadOnly, Converter={StaticResource InverseBooleanConverter}}" custom:FocusAttacher.Focus="{Binding ReadOnly, Converter={StaticResource InverseBooleanConverter}}"/> </DataTemplate> </custom:EditTemplateSelector.TimeSpanTemplate> </custom:EditTemplateSelector></ResourceDictionary>Not working code:
<controls:RadOutlookBar Grid.Row="2" ItemsSource="{Binding Groups}" IsMinimizable="False"> <controls:RadOutlookBar.TitleTemplate> <DataTemplate> <Label Content="{Binding Header}"/> </DataTemplate> </controls:RadOutlookBar.TitleTemplate> <controls:RadOutlookBar.ItemTemplate> <DataTemplate> <Label Content="{Binding Header}"/> </DataTemplate> </controls:RadOutlookBar.ItemTemplate> <controls:RadOutlookBar.ContentTemplate> <DataTemplate> <telerik:RadGridView Grid.Row="2" ItemsSource="{Binding DataObjects, Mode=TwoWay}" SelectionMode="Single" AutoGenerateColumns="False" CanUserDeleteRows="False" CanUserFreezeColumns="False" CanUserReorderColumns="False" CanUserInsertRows="False" RowHeight="30" ColumnWidth="200" BorderThickness="0" ShowColumnHeaders="False" ShowGroupPanel="False" RowIndicatorVisibility="Collapsed" EditTriggers="CellClick"> <telerik:RadGridView.Columns> <aucxis:GridViewDataColumn DataMemberBinding="{Binding SubID}" IsReadOnly="True"/> <aucxis:GridViewDataColumn DataMemberBinding="{Binding DataValue}" CellEditTemplateSelector="{StaticResource EditTemplateSelector}" Width="Auto"/> </telerik:RadGridView.Columns> </telerik:RadGridView> </DataTemplate> </controls:RadOutlookBar.ContentTemplate></controls:RadOutlookBar>So when I use this last implementation the datatemplates in the Edittemplateselector returns null.
They are In the same project in the same view, I just don't get it :)