5
// Eric Maupin <ermau@xamarin.com>
7
// Copyright (c) 2012 Xamarin, Inc.
9
// Permission is hereby granted, free of charge, to any person obtaining a copy
10
// of this software and associated documentation files (the "Software"), to deal
11
// in the Software without restriction, including without limitation the rights
12
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
// copies of the Software, and to permit persons to whom the Software is
14
// furnished to do so, subject to the following conditions:
16
// The above copyright notice and this permission notice shall be included in
17
// all copies or substantial portions of the Software.
19
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29
using System.Windows.Controls;
30
using System.Windows.Input;
31
using System.Windows.Media;
33
using Xwt.WPFBackend.Utilities;
35
namespace Xwt.WPFBackend
37
public class TextEntryBackend
38
: WidgetBackend, ITextEntryBackend
40
public TextEntryBackend()
42
Widget = new ExTextBox();
43
TextBox.IsReadOnlyCaretVisible = true;
46
protected override double DefaultNaturalWidth
51
public virtual string Text
53
get { return TextBox.Text; }
54
set { TextBox.Text = value; }
57
public string PlaceholderText
59
get { return TextBox.PlaceholderText; }
60
set { TextBox.PlaceholderText = value; }
65
get { return TextBox.IsReadOnly; }
66
set { TextBox.IsReadOnly = true; }
71
get { return TextBox.ShowFrame; }
72
set { TextBox.ShowFrame = value; }
75
public override void EnableEvent (object eventId)
77
base.EnableEvent (eventId);
79
if (eventId is TextEntryEvent)
81
switch ((TextEntryEvent)eventId)
83
// TODO: Should we ignore this for placeholder changes?
84
case TextEntryEvent.Changed:
85
TextBox.TextChanged += OnTextChanged;
91
public override void DisableEvent (object eventId)
93
base.DisableEvent (eventId);
95
if (eventId is TextEntryEvent)
97
switch ((TextEntryEvent)eventId)
99
case TextEntryEvent.Changed:
100
TextBox.TextChanged -= OnTextChanged;
106
protected ExTextBox TextBox
108
get { return (ExTextBox) Widget; }
111
protected new ITextEntryEventSink EventSink {
112
get { return (ITextEntryEventSink)base.EventSink; }
115
private void OnTextChanged (object s, TextChangedEventArgs e)
117
Xwt.Engine.Toolkit.Invoke (EventSink.OnChanged);
b'\\ No newline at end of file'