Skip to content

Commit

Permalink
Focussing is working
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrenn committed May 24, 2019
1 parent d960e5b commit b29562e
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/DatenMeister.WPF/Forms/Base/DetailFormControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<UserControl.CommandBindings>
<CommandBinding Command="Copy" Executed="CommandBinding_OnExecuted" />
Expand Down
34 changes: 30 additions & 4 deletions src/DatenMeister.WPF/Forms/Base/DetailFormControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Windows.Input;
using System.Windows.Media;
using Autofac;
using BurnSystems.Logging;
using DatenMeister.Core.EMOF.Implementation;
using DatenMeister.Core.EMOF.Interface.Common;
using DatenMeister.Core.EMOF.Interface.Reflection;
Expand All @@ -30,6 +31,14 @@ namespace DatenMeister.WPF.Forms.Base
/// </summary>
public partial class DetailFormControl : UserControl, INavigationGuest, IHasSelectedItems, IHasTitle
{
/// <summary>
/// Stores the logger
/// </summary>
private static readonly ClassLogger logger = new ClassLogger(typeof(DetailFormControl));

/// <summary>
/// Stores the number of fields
/// </summary>
private int _fieldCount;

/// <summary>
Expand Down Expand Up @@ -64,7 +73,10 @@ public DetailFormControl()
/// Gets or sets a value indicating whether new properties may be added by the user to the element
/// </summary>
public bool AllowNewProperties { get; set; }


/// <summary>
/// Gets the attached element which is allocated in the navigation host
/// </summary>
public IElement AttachedElement => NavigationHost.AttachedElement;

/// <summary>
Expand All @@ -74,9 +86,15 @@ public DetailFormControl()
EffectiveForm?.getOrDefault<double>(_FormAndFields._Form.defaultWidth) ?? 0.0,
EffectiveForm?.getOrDefault<double>(_FormAndFields._Form.defaultHeight) ?? 0.0
);


/// <summary>
/// Gets the list of the item fields being used to store the information into the item
/// </summary>
public List<IDetailField> ItemFields { get; } = new List<IDetailField>();

/// <summary>
/// Gets the list of field information being allocated to the form but not to the detail form
/// </summary>
public List<IDetailField> AttachedItemFields { get; } = new List<IDetailField>();

public IObject GetSelectedItem()
Expand Down Expand Up @@ -417,7 +435,7 @@ private void CreateRows(IReflectiveCollection fields)
}

// Checks whether the control element shall be stored in
// the detail element iself or within the attached fields
// the detail element itself or within the attached fields
if (field.getOrNull<bool>(_FormAndFields._FieldData.isAttached) == true)
{
AttachedItemFields.Add(detailElement);
Expand All @@ -430,7 +448,15 @@ private void CreateRows(IReflectiveCollection fields)
// Check, if element shall be focused
if (!anyFocused && flags.CanBeFocused)
{
contentBlock.Focus();
// For what ever, we have to set the focus via the invoking and not directly
Dispatcher.BeginInvoke((Action)(() =>
{
if (!contentBlock.Focus())
{
logger.Debug("No keyboard focus set");
}
}));

anyFocused = true;
}
}
Expand Down
9 changes: 5 additions & 4 deletions src/DatenMeister.WPF/Windows/DetailFormWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public void SetFocus()
}
else
{
MainContent?.Focus();
MainContent.Focus();
}
}

Expand Down Expand Up @@ -200,8 +200,6 @@ public void SetMainContent(UIElement element)
{
Title = title.Title;
}

Focus();
}

/// <summary>
Expand Down Expand Up @@ -330,7 +328,10 @@ private void CreateDetailForm()
}
}
}


/// <summary>
/// Sets the effective form by using the viewdefinition
/// </summary>
private void UpdateActualViewDefinition()
{
var viewFinder = GiveMe.Scope.Resolve<ViewFinderImpl>();
Expand Down

0 comments on commit b29562e

Please sign in to comment.