Showing ScriptableObjects in multi selection dropdown menu in Unity - unity3d

How should I create PropertyAttribute and PropertyDrawer to show ScriptableObjects in dropdown menu in Inspector for multi selecting ?

I've published a repository on Github which solve this problem. It is for multi selecting in dropdown menu in Inspector.
In Github links you have access to example folder and unitypackage in release page but if you don't want to go to the links or any problem happens to the links, you can follow this instruction:
ScriptableObjectMultiSelectDropdown:
ScriptableObjectMultiSelectDropdown is an attribute for the Unity Inspector.
It is used for showing ScriptableObjects which are created in your project, in dropdown menu and select multiple of them in Inspector.
Code:
ScriptableObjectReference.cs:
// Copyright (c) ATHellboy (Alireza Tarahomi) Limited. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root.
using System;
using UnityEngine;
namespace ScriptableObjectMultiSelectDropdown
{
/// <summary>
/// Because you can't make a PropertyDrawer for arrays or generic lists themselves,
/// I had to create parent class as an abstract layer.
/// </summary>
[Serializable]
public class ScriptableObjectReference
{
public ScriptableObject[] values;
}
}
ScriptableObjectMultiSelectDropdownAttribute.cs:
// Copyright (c) ATHellboy (Alireza Tarahomi) Limited. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root.
using System;
using UnityEngine;
namespace ScriptableObjectMultiSelectDropdown
{
/// <summary>
/// Indicates how selectable scriptableObjects should be collated in drop-down menu.
/// </summary>
public enum ScriptableObjectGrouping
{
/// <summary>
/// No grouping, just show type names in a list; for instance, "MainFolder > NestedFolder > SpecialScriptableObject".
/// </summary>
None,
/// <summary>
/// Group classes by namespace and show foldout menus for nested namespaces; for
/// instance, "MainFolder >> NestedFolder >> SpecialScriptableObject".
/// </summary>
ByFolder,
/// <summary>
/// Group scriptableObjects by folder; for instance, "MainFolder > NestedFolder >> SpecialScriptableObject".
/// </summary>
ByFolderFlat
}
/// <example>
/// <para>Usage Examples</para>
/// <code language="csharp"><![CDATA[
/// using UnityEngine;
/// using ScriptableObjectDropdown;
///
/// [CreateAssetMenu(menuName = "Create Block")]
/// public class Block : ScriptableObject
/// {
/// // Some fields
/// }
///
/// public class BlockManager : MonoBehaviour
/// {
/// [ScriptableObjectMultiSelectDropdown(typeof(Block))]
/// public ScriptableObjectReference firstTargetBlocks;
///
/// // or
///
/// [ScriptableObjectMultiSelectDropdown(typeof(Block), grouping = ScriptableObjectGrouping.ByFolder)]
/// public ScriptableObjectReference secondTargetBlocks;
/// }
///
/// // or
///
/// [CreateAssetMenu(menuName = "Create Block Manager Settings")]
/// public class BlockManagerSetting : ScriptableObject
/// {
/// [ScriptableObjectMultiSelectDropdown(typeof(Block))]
/// public ScriptableObjectReference firstTargetBlocks;
///
/// // or
///
/// [ScriptableObjectMultiSelectDropdown(typeof(Block), grouping = ScriptableObjectGrouping.ByFolderFlat)]
/// public ScriptableObjectReference secondTargetBlocks;
/// }
/// ]]></code>
/// </example>
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false)]
public class ScriptableObjectMultiSelectDropdownAttribute : PropertyAttribute
{
public ScriptableObjectGrouping grouping = ScriptableObjectGrouping.None;
private Type _baseType;
public Type BaseType
{
get { return _baseType; }
private set { _baseType = value; }
}
public ScriptableObjectMultiSelectDropdownAttribute(Type baseType)
{
_baseType = baseType;
}
}
}
Put this one in Editor folder:
ScriptableObjectMultiSelectionDropdownDrawer.cs:
// Copyright (c) ATHellboy (Alireza Tarahomi) Limited. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root.
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System.Reflection;
using System.Linq;
namespace ScriptableObjectMultiSelectDropdown.Editor
{
// TODO: Mixed value (-) for selecting multi objects
[CustomPropertyDrawer(typeof(ScriptableObjectReference))]
[CustomPropertyDrawer(typeof(ScriptableObjectMultiSelectDropdownAttribute))]
public class ScriptableObjectMultiSelectionDropdownDrawer : PropertyDrawer
{
private static ScriptableObjectMultiSelectDropdownAttribute _attribute;
private static List<ScriptableObject> _scriptableObjects = new List<ScriptableObject>();
private static List<ScriptableObject> _selectedScriptableObjects = new List<ScriptableObject>();
private static readonly int _controlHint = typeof(ScriptableObjectMultiSelectDropdownAttribute).GetHashCode();
private static GUIContent _popupContent = new GUIContent();
private static int _selectionControlID;
private static readonly GenericMenu.MenuFunction2 _onSelectedScriptableObject = OnSelectedScriptableObject;
private static bool isChanged;
static ScriptableObjectMultiSelectionDropdownDrawer()
{
EditorApplication.projectChanged += ClearCache;
}
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
ScriptableObjectMultiSelectDropdownAttribute castedAttribute = attribute as ScriptableObjectMultiSelectDropdownAttribute;
if (_scriptableObjects.Count == 0)
{
GetScriptableObjects(castedAttribute);
}
Draw(position, label, property, castedAttribute);
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
return EditorStyles.popup.CalcHeight(GUIContent.none, 0);
}
/// <summary>
/// How you can get type of field which it uses PropertyAttribute
/// </summary>
private static Type GetPropertyType(SerializedProperty property)
{
Type parentType = property.serializedObject.targetObject.GetType();
FieldInfo fieldInfo = parentType.GetField(property.propertyPath);
if (fieldInfo != null)
{
return fieldInfo.FieldType;
}
return null;
}
private static bool ValidateProperty(SerializedProperty property)
{
Type propertyType = GetPropertyType(property);
if (propertyType == null)
{
return false;
}
if (propertyType != typeof(ScriptableObjectReference))
{
return false;
}
return true;
}
/// <summary>
/// When new ScriptableObject added to the project
/// </summary>
private static void ClearCache()
{
_scriptableObjects.Clear();
}
/// <summary>
/// Gets ScriptableObjects just when it is a first time or new ScriptableObject added to the project
/// </summary>
private static void GetScriptableObjects(ScriptableObjectMultiSelectDropdownAttribute attribute)
{
string[] guids = AssetDatabase.FindAssets(String.Format("t:{0}", attribute.BaseType));
for (int i = 0; i < guids.Length; i++)
{
_scriptableObjects.Add(AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(guids[i]), attribute.BaseType) as ScriptableObject);
}
}
/// <summary>
/// Checks if the ScriptableObject is selected or not by checking if the list contains it.
/// </summary>
private static bool ResolveSelectedScriptableObject(ScriptableObject scriptableObject)
{
if (_selectedScriptableObjects == null)
{
return false;
}
return _selectedScriptableObjects.Contains(scriptableObject);
}
private static void Draw(Rect position, GUIContent label,
SerializedProperty property, ScriptableObjectMultiSelectDropdownAttribute attribute)
{
if (label != null && label != GUIContent.none)
position = EditorGUI.PrefixLabel(position, label);
if (ValidateProperty(property))
{
if (_scriptableObjects.Count != 0)
{
UpdateScriptableObjectSelectionControl(position, label, property.FindPropertyRelative("values"), attribute);
}
else
{
EditorGUI.LabelField(position, "There is no this type asset in the project");
}
}
else
{
EditorGUI.LabelField(position, "Use it with ScriptableObjectReference");
}
}
/// <summary>
/// Iterats through the property for finding selected ScriptableObjects
/// </summary>
private static ScriptableObject[] Read(SerializedProperty property)
{
List<ScriptableObject> selectedScriptableObjects = new List<ScriptableObject>();
SerializedProperty iterator = property.Copy();
SerializedProperty end = iterator.GetEndProperty();
while (!SerializedProperty.EqualContents(iterator, end) && iterator.Next(true))
{
if (iterator.propertyType == SerializedPropertyType.ObjectReference)
{
selectedScriptableObjects.Add(iterator.objectReferenceValue as ScriptableObject);
}
}
return selectedScriptableObjects.ToArray();
}
/// <summary>
/// Iterats through the property for storing selected ScriptableObjects
/// </summary>
private static void Write(SerializedProperty property, ScriptableObject[] scriptableObjects)
{
// Faster way
// var w = new System.Diagnostics.Stopwatch();
// w.Start();
int i = 0;
SerializedProperty iterator = property.Copy();
iterator.arraySize = scriptableObjects.Length;
SerializedProperty end = iterator.GetEndProperty();
while (!SerializedProperty.EqualContents(iterator, end) && iterator.Next(true))
{
if (iterator.propertyType == SerializedPropertyType.ObjectReference)
{
iterator.objectReferenceValue = scriptableObjects[i];
i++;
}
}
// w.Stop();
// long milliseconds = w.ElapsedMilliseconds;
// Debug.Log(w.Elapsed.TotalMilliseconds + " ms");
// Another way
// property.arraySize = scriptableObjects.Length;
// for (int i = 0; i < property.arraySize; i++)
// {
// property.GetArrayElementAtIndex(i).objectReferenceValue = scriptableObjects[i];
// }
}
private static void UpdateScriptableObjectSelectionControl(Rect position, GUIContent label,
SerializedProperty property, ScriptableObjectMultiSelectDropdownAttribute attribute)
{
ScriptableObject[] output = DrawScriptableObjectSelectionControl(position, label, Read(property), property, attribute);
if (isChanged)
{
isChanged = false;
Write(property, output);
}
}
private static ScriptableObject[] DrawScriptableObjectSelectionControl(Rect position, GUIContent label,
ScriptableObject[] scriptableObjects, SerializedProperty property, ScriptableObjectMultiSelectDropdownAttribute attribute)
{
bool triggerDropDown = false;
int controlID = GUIUtility.GetControlID(_controlHint, FocusType.Keyboard, position);
switch (Event.current.GetTypeForControl(controlID))
{
case EventType.ExecuteCommand:
if (Event.current.commandName == "ScriptableObjectReferenceUpdated")
{
if (_selectionControlID == controlID)
{
if (scriptableObjects != _selectedScriptableObjects.ToArray())
{
scriptableObjects = _selectedScriptableObjects.ToArray();
isChanged = true;
}
_selectionControlID = 0;
_selectedScriptableObjects = null;
}
}
break;
case EventType.MouseDown:
if (GUI.enabled && position.Contains(Event.current.mousePosition))
{
GUIUtility.keyboardControl = controlID;
triggerDropDown = true;
Event.current.Use();
}
break;
case EventType.KeyDown:
if (GUI.enabled && GUIUtility.keyboardControl == controlID)
{
if (Event.current.keyCode == KeyCode.Return || Event.current.keyCode == KeyCode.Space)
{
triggerDropDown = true;
Event.current.Use();
}
}
break;
case EventType.Repaint:
if (scriptableObjects.Length == 0)
{
_popupContent.text = "Nothing";
}
else if (scriptableObjects.Length == _scriptableObjects.Count)
{
_popupContent.text = "Everything";
}
else if (scriptableObjects.Length >= 2)
{
_popupContent.text = "Mixed ...";
}
else
{
_popupContent.text = scriptableObjects[0].name;
}
EditorStyles.popup.Draw(position, _popupContent, controlID);
break;
}
if (triggerDropDown)
{
_selectionControlID = controlID;
_selectedScriptableObjects = scriptableObjects.ToList();
DisplayDropDown(position, scriptableObjects, attribute.grouping);
}
return scriptableObjects;
}
private static void DisplayDropDown(Rect position, ScriptableObject[] selectedScriptableObject, ScriptableObjectGrouping grouping)
{
var menu = new GenericMenu();
menu.AddItem(new GUIContent("Nothing"), selectedScriptableObject.Length == 0, _onSelectedScriptableObject, null);
menu.AddItem(new GUIContent("Everything"),
(_scriptableObjects.Count != 0 && selectedScriptableObject.Length == _scriptableObjects.Count),
_onSelectedScriptableObject, _scriptableObjects.ToArray());
for (int i = 0; i < _scriptableObjects.Count; ++i)
{
var scriptableObject = _scriptableObjects[i];
string menuLabel = MakeDropDownGroup(scriptableObject, grouping);
if (string.IsNullOrEmpty(menuLabel))
continue;
var content = new GUIContent(menuLabel);
menu.AddItem(content, ResolveSelectedScriptableObject(scriptableObject), _onSelectedScriptableObject, scriptableObject);
}
menu.DropDown(position);
}
private static void OnSelectedScriptableObject(object userData)
{
if (userData == null)
{
_selectedScriptableObjects.Clear();
}
else if (userData.GetType().IsArray)
{
_selectedScriptableObjects = (userData as ScriptableObject[]).ToList();
}
else
{
ScriptableObject scriptableObject = userData as ScriptableObject;
if (!ResolveSelectedScriptableObject(scriptableObject))
{
_selectedScriptableObjects.Add(scriptableObject);
}
else
{
_selectedScriptableObjects.Remove(scriptableObject);
}
}
var scriptableObjectReferenceUpdatedEvent = EditorGUIUtility.CommandEvent("ScriptableObjectReferenceUpdated");
EditorWindow.focusedWindow.SendEvent(scriptableObjectReferenceUpdatedEvent);
}
private static string FindScriptableObjectFolderPath(ScriptableObject scriptableObject)
{
string path = AssetDatabase.GetAssetPath(scriptableObject);
path = path.Replace("Assets/", "");
path = path.Replace(".asset", "");
return path;
}
private static string MakeDropDownGroup(ScriptableObject scriptableObject, ScriptableObjectGrouping grouping)
{
string path = FindScriptableObjectFolderPath(scriptableObject);
switch (grouping)
{
default:
case ScriptableObjectGrouping.None:
path = path.Replace("/", " > ");
return path;
case ScriptableObjectGrouping.ByFolder:
return path;
case ScriptableObjectGrouping.ByFolderFlat:
int last = path.LastIndexOf('/');
string part1 = path.Substring(0, last);
string part2 = path.Substring(last);
path = part1.Replace("/", " > ") + part2;
return path;
}
}
}
}
Usage Example:
Create ScriptableObject class which you want to create specified objects by that.
using UnityEngine;
[CreateAssetMenu(menuName = "Create Block")]
public class Block : ScriptableObject
{
// Some fields
}
Create ScriptableObjects in the project.
Use ScriptableObjectMultiSelectDropdown attribute by setting type of specified ScriptableObject derived class and optional grouping (Default grouping is None) like this in MonoBeahviour or ScriptableObject derived classes.
MonoBehavior:
using ScriptableObjectMultiSelectDropdown;
using UnityEngine;
public class BlockManager : MonoBehaviour
{
// Without grouping (default is None)
[ScriptableObjectMultiSelectDropdown(typeof(Block))]
public ScriptableObjectReference firstTargetBlocks;
// By grouping
[ScriptableObjectMultiSelectDropdown(typeof(Block), grouping = ScriptableObjectGrouping.ByFolder)]
public ScriptableObjectReference secondTargetBlocks;
}
ScriptableObject:
using UnityEngine;
using ScriptableObjectMultiSelectDropdown;
[CreateAssetMenu(menuName = "Create Block Manager Settings")]
public class BlockManagerSettings : ScriptableObject
{
// Without grouping (default is None)
[ScriptableObjectMultiSelectDropdown(typeof(Block))]
public ScriptableObjectReference firstTargetBlocks;
// By grouping
[ScriptableObjectMultiSelectDropdown(typeof(Block), grouping = ScriptableObjectGrouping.ByFolderFlat)]
public ScriptableObjectReference secondTargetBlocks;
}

Related

FlowListView not fully updating UI when changing ObservableCollection<T>

When I remove objects from the list the UI doesn't reflect the current state of the list, normally failling by only one item.
Example: If I remove 4 items, on the UI only shows that I removed 3 items
private ObservableCollection<Card> _cards;
public ObservableCollection<Card> Cards
{
get
{
if (_cards == null)
{
_cards = new ObservableCollection<Card>();
return _cards;
}
return _cards;
}
set
{
SetValue(ref _cards, value);
}
}
My remove method
private void RemoveFromCards(Card card)
{
for (int i = Cards.Count - 1; i >= 0; i--)
{
if (Cards[i].Id == card.Id)
{
Cards.RemoveAt(i);
/* I tried this but doesn't work also
*
*
ObservableCollection<Card> copy = Cards;
copy.RemoveAt(i);
Cards = copy;
*/
}
}
}
Calling remove method
private void RemoveCardsFromView(List<Archive> cards)
{
foreach (Archive a in cards)
{
Card c = new Card {Id = a.CardId};
RemoveFromCards(c);
}
}
Calling code
public async Task RefreshCardsView()
{
if (!CrossConnectivity.Current.IsConnected)
{
BuildToast(false,"No internet connection");
return;
}
try
{
JsonResult cards = (JsonResult) await HttpMiddleman.GetCards();
RemoveCardsFromView(cards.Data.DeletedCards);
AddCardsToView(cards.Data.AddedCards);
}
catch (Exception e)
{
Debug.WriteLine(e.Message);
BuildToast(false,"Could not refresh");
}
}
My binding in FlowListView
<controls:FlowListView x:Name="Board" HasUnevenRows="True"
BackgroundColor="Black"
FlowColumnCount="2"
FlowItemTappedCommand="{Binding ExecuteActionCommand}"
FlowColumnMinWidth="110"
IsPullToRefreshEnabled="True"
IsRefreshing="{Binding IsRefreshing}"
RefreshCommand="{Binding RefreshViewCommand}"
FlowItemsSource="{Binding Cards}"> .....
Thanks in advance guys
make sure that you fire correctly OnPropertyChanged after SetValue() in property statement
and
try with this class (from xamarin) and pass ienumerable of card instead card only object.
Example
private void RemoveFromCards(Card card)
{
Cards.RemoveRange(new []{card});
}
//or directly from
private void RemoveCardsFromView(List<Archive> cards)
{
Cards.RemoveRange(cards.Select(s=> new Card {Id = a.CardId}));
}
/// <summary>
/// Represents a dynamic data collection that provides notifications when items get added, removed, or when the whole list is refreshed.
/// </summary>
/// <typeparam name="T"></typeparam>
public class ObservableRangeCollection<T> : ObservableCollection<T>
{
/// <summary>
/// Initializes a new instance of the System.Collections.ObjectModel.ObservableCollection(Of T) class.
/// </summary>
public ObservableRangeCollection()
: base()
{
}
/// <summary>
/// Initializes a new instance of the System.Collections.ObjectModel.ObservableCollection(Of T) class that contains elements copied from the specified collection.
/// </summary>
/// <param name="collection">collection: The collection from which the elements are copied.</param>
/// <exception cref="System.ArgumentNullException">The collection parameter cannot be null.</exception>
public ObservableRangeCollection(IEnumerable<T> collection)
: base(collection)
{
}
/// <summary>
/// Adds the elements of the specified collection to the end of the ObservableCollection(Of T).
/// </summary>
public void AddRange(IEnumerable<T> collection, NotifyCollectionChangedAction notificationMode = NotifyCollectionChangedAction.Add)
{
if (collection == null)
throw new ArgumentNullException("collection");
CheckReentrancy();
if (notificationMode == NotifyCollectionChangedAction.Reset)
{
foreach (var i in collection)
{
Items.Add(i);
}
OnPropertyChanged(new PropertyChangedEventArgs("Count"));
OnPropertyChanged(new PropertyChangedEventArgs("Item[]"));
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
return;
}
int startIndex = Count;
var changedItems = collection is List<T> ? (List<T>)collection : new List<T>(collection);
foreach (var i in changedItems)
{
Items.Add(i);
}
OnPropertyChanged(new PropertyChangedEventArgs("Count"));
OnPropertyChanged(new PropertyChangedEventArgs("Item[]"));
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, changedItems, startIndex));
}
/// <summary>
/// Removes the first occurence of each item in the specified collection from ObservableCollection(Of T).
/// </summary>
public void RemoveRange(IEnumerable<T> collection)
{
if (collection == null)
throw new ArgumentNullException("collection");
foreach (var i in collection)
Items.Remove(i);
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
}
/// <summary>
/// Clears the current collection and replaces it with the specified item.
/// </summary>
public void Replace(T item)
{
ReplaceRange(new T[] { item });
}
/// <summary>
/// Clears the current collection and replaces it with the specified collection.
/// </summary>
public void ReplaceRange(IEnumerable<T> collection)
{
if (collection == null)
throw new ArgumentNullException("collection");
Items.Clear();
AddRange(collection, NotifyCollectionChangedAction.Reset);
}
}

How do I fix this error when trying to use the Watson SDK for Unity?

thanks for taking a look at this. I'm new to Unity and struggling to understand how to fix this error.
Assets/Watson/Scripts/Logging/Logger.cs(115,53): error CS0311: The type IBM.Watson.DeveloperCloud.Logging.LogSystem' cannot be used as type parameter T in the generic type or method Singleton. There is no implicit reference conversion from IBM.Watson.DeveloperCloud.Logging.LogSystem' to `UnityEngine.MonoBehaviour
This is the line causing the error:
public static LogSystem Instance { get { return Singleton<LogSystem>.Instance; } }
And this is it in context:
/// <summary>
/// This singleton class maintains the of list of installed reactors and handles all LogRecord
/// objects. See the static class Log for functions the end user of this system should actually
/// be calling. This class is thread safe.
/// </summary>
public class LogSystem
{
#region Public Properties
/// <summary>
/// Returns the singleton instance of the Logger object.
/// </summary>
**public static LogSystem Instance { get { return Singleton<LogSystem>.Instance; } }**
#endregion
#region Private Data
private static bool sm_bInstalledDefaultReactors = false;
List<ILogReactor> m_Reactors = new List<ILogReactor>();
#endregion
#region Public Functions
public static List<ILogReactor> ReactorsInstalled
{
get
{
return LogSystem.Instance.m_Reactors;
}
}
/// <summary>
/// Install a default debug and file reactor.
/// </summary>
public static void InstallDefaultReactors(int logHistory = 2, LogLevel logLevelFileReactor = LogLevel.STATUS)
{
if (!sm_bInstalledDefaultReactors)
{
// install the default reactors...
sm_bInstalledDefaultReactors = true;
#if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID
LogSystem.Instance.InstallReactor(new DebugReactor());
#endif
if (!string.IsNullOrEmpty(Constants.Path.LOG_FOLDER) && !System.IO.Directory.Exists(Application.persistentDataPath + Constants.Path.LOG_FOLDER))
System.IO.Directory.CreateDirectory(Application.persistentDataPath + Constants.Path.LOG_FOLDER);
LogSystem.Instance.InstallReactor(new FileReactor(Application.persistentDataPath + Constants.Path.LOG_FOLDER + "/" + Application.productName + ".log", logLevelFileReactor, logHistory));
Application.logMessageReceived += UnityLogCallback;
}
}
static void UnityLogCallback(string condition, string stacktrace, LogType type)
{
if (type == LogType.Exception)
Log.Critical("Unity", "Unity Exception {0} : {1}", condition, stacktrace);
}
/// <summary>
/// Installs a reactor into this Logger.
/// </summary>
/// <param name="reactor">The reactor object.</param>
public void InstallReactor(ILogReactor reactor)
{
lock (m_Reactors)
{
m_Reactors.Add(reactor);
}
// set our default reactor flag to true if the user installs their own reactors.
sm_bInstalledDefaultReactors = true;
}
/// <summary>
/// Removes a reactor from this Logger.
/// </summary>
/// <param name="reactor">The reactor to remove.</param>
/// <returns>Returns true on success.</returns>
public bool RemoveReactor(ILogReactor reactor)
{
lock (m_Reactors)
{
return m_Reactors.Remove(reactor);
}
}
/// <summary>
/// Send the given LogRecord to all installed reactors.
/// </summary>
/// <param name="log">The LogRecord to pass to all reactors.</param>
public void ProcessLog(LogRecord log)
{
lock (m_Reactors)
{
foreach (var reactor in m_Reactors)
reactor.ProcessLog(log);
}
}
#endregion
}
public static LogSystem Instance
{
get
{
return instance;
}
}
private static LogSystem instance;
// Ctor of the class
public LogSystem()
{
if(instance == null) { instance = this;}
}
This is a very basic singleton pattern implementation. You can find more advanced ones online.

How to get actual value and validate of CustomTextbox Text in ViewModel

I have created custom component for displaying text with either Simple or Password mode, intention to develop this control is the Silverlight does not support custom TextMode (like Password or Text).
This is my requirement
In addition to the access rights it will be possible for organizations to specify restricted access to certain fields in the database. The access restriction to these fields will be Update and Redacted, thus meaning if a specific field has true against Update then a user will be able to update the field as well as viewing it, and if the field has true against Redacted then the user will only be able to see a redacted value in the filed (possibly asterisks - * * * * *). It will be possible to set a field to being Update-able and Redacted, thus meaning a user will see the redacted view but still be able to go and update the field with a new value. Such a requirement is mostly used when holding sensitive information against a contact or information which could be used to discriminate against the contact.
I have created custom control for this requirement and it is working perfectly. i am able to set TextMode dynamically but i couldn't able to get the original value in my ViewModel. (I am able to get original value in View but can't in ViewModel)
If i am access the original value in View using following then it is work.
string s = UserName.Text;
but not getting this value in ViewModel it is giving me like **.
Following is the complete code for PasswordTextBox control.
namespace QSys.Library.Controls
{
public partial class PasswordTextBox : TextBox
{
#region Variables
private string text = string.Empty;
private string passwordChar = "*";
private int selectionLength = 0;
#endregion
#region Properties
/// <summary>
/// The text associated with the control.
/// </summary>
public new string Text
{
get { return text; }
set
{
text = value;
DisplayMaskedCharacters();
}
}
/// <summary>
/// Indicates the character to display for password input.
/// </summary>
public string PasswordChar
{
get { return passwordChar; }
set { passwordChar = value; }
}
/// <summary>
/// Indicates the input text mode to display for either text or password.
/// </summary>
public Mode TextMode
{
get { return (Mode)GetValue(TextModeProperty); }
set { SetValue(TextModeProperty, value); }
}
public static readonly DependencyProperty TextModeProperty = DependencyProperty.Register("TextMode", typeof(Mode), typeof(PasswordTextBox), new PropertyMetadata(default(Mode)));
#endregion
#region Constructors
public PasswordTextBox()
{
this.Loaded += new RoutedEventHandler(PasswordTextBox_Loaded);
}
#endregion
#region Event Handlers
void PasswordTextBox_Loaded(object sender, System.Windows.RoutedEventArgs e)
{
if (this.TextMode == Mode.Password)
{
text = base.Text;
this.TextChanged += new TextChangedEventHandler(PasswordTextBox_TextChanged);
this.KeyDown += new KeyEventHandler(PasswordTextBox_KeyDown);
this.SelectionChanged += new RoutedEventHandler(PasswordTextBox_SelectionChanged);
DisplayMaskedCharacters();
}
this.Loaded -= PasswordTextBox_Loaded;
}
void PasswordTextBox_SelectionChanged(object sender, RoutedEventArgs e)
{
selectionLength = this.SelectionLength;
}
public void PasswordTextBox_TextChanged(object sender, TextChangedEventArgs e)
{
if (base.Text.Length >= text.Length)
text += base.Text.Substring(text.Length);
else
{
int cursorPosition = this.SelectionStart;
selectionLength = (selectionLength > 1) ? selectionLength : 1;
text = text.Remove(cursorPosition, selectionLength);
}
DisplayMaskedCharacters();
selectionLength = 0;
}
public void PasswordTextBox_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
{
int cursorPosition = this.SelectionStart;
// Handle Delete and Backspace Keys Appropriately
if (e.Key == System.Windows.Input.Key.Back && cursorPosition > 0)
{
DeleteAt(cursorPosition);
}
else if (e.Key == System.Windows.Input.Key.Delete)
{
DeleteAt(cursorPosition);
}
else
{
if (selectionLength > 0) text = text.Remove(cursorPosition, selectionLength);
base.Text = text;
this.Select((cursorPosition > text.Length ? text.Length : cursorPosition), 0);
DisplayMaskedCharacters();
}
selectionLength = 0;
}
#endregion
#region Private Methods
private void DisplayMaskedCharacters()
{
int cursorPosition = this.SelectionStart;
// This changes the Text property of the base TextBox class to display all Asterisks in the control
base.Text = new string(passwordChar.ToCharArray()[0], text.Length);
this.Select((cursorPosition > text.Length ? text.Length : cursorPosition), 0);
}
private void DeleteAt(int position)
{
if (text.Length > position)
{
text = text.Remove(position, 1);
base.Text = base.Text.Remove(position, 1);
}
}
#endregion
}
}
LoginView.xaml
<control:PasswordTextBox x:Name="UserName" TabIndex="1" Grid.Row="1" TextMode="Password" Text="{Binding Path=LoginModelValue.UserName, Mode=TwoWay,ValidatesOnNotifyDataErrors=True, ValidatesOnExceptions=True, ValidatesOnDataErrors=True, NotifyOnValidationError=True}" HorizontalAlignment="Left" VerticalAlignment="Top" Grid.Column="1" Width="200" Height="25" Validatevalue:UpdateSourceTriggerHelper.UpdateSourceTrigger="True"/>
LoginViewModel.cs
public class LoginViewModel : INotifyPropertyChanged, IRegionMemberLifetime
{
public LoginModel LoginModelValue
{
get { return _LoginModelValue; }
set
{
_LoginModelValue = value;
OnPropertyChanged("LoginModelValue");
}
}
}
LoginModel.cs
namespace QSys.Model
{
public class LoginModel : INotifyPropertyChanged
{
#region Variables
private string _userName;
private string _password;
#endregion
#region Constructor
public LoginModel()
{
}
#endregion
#region Properties
[CustomValidation(typeof(PasswordTextBox), "IsValidUserName")]
[Required(ErrorMessage = "User Name is required")]
[Display(Name = "UserName")]
[StringLength(50)]
//[RegularExpression(#"^[a-zA-Z\\0-9\\.\\,\\'\s]+$", ErrorMessage = "Please enter right format.")]
public string UserName
{
get { return _userName; }
set
{
_userName = value;
OnPropertyChanged("UserName");
ValidateProperty("UserName", value);
}
}
[Required(ErrorMessage = "Password is required")]
[Display(Name = "Password")]
[StringLength(10)]
public string Password
{
get { return _password; }
set
{
_password = value;
OnPropertyChanged("Password");
ValidateProperty("Password", value);
}
}
#endregion
#region INotifyPropertyChanged
public event PropertyChangedEventHandler PropertyChanged = delegate { };
private void OnPropertyChanged(string propertyName)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
#endregion
#region Private Methods
public bool IsValidObject()
{
ICollection<ValidationResult> results = new Collection<ValidationResult>();
return Validator.TryValidateObject(this, new ValidationContext(this, null, null), results, true) && results.Count == 0;
}
public void ValidateProperty(string propertyName, object value)
{
Validator.ValidateProperty(value, new ValidationContext(this, null, null) { MemberName = propertyName });
}
#endregion
}
}
**I am looking for solution since two days without any luck.
Please help me if you have any solution, your comments or suggestion would be highly appreciated.**
Thanks
Imdadhusen
Wouldn't it be easier to build your own UserControl around the regular TextBox and PasswordBox and just switching their visibility when your dependency property TextMode changes? You could then have a single VM for the UserControl with property Value and bind in TwoWay mode both the TextProperty of the TextBox and the Password property of the PasswordBox to it.
I have resolved using following code.
I am missing Mode=TwoWay in LoginView.xaml:
<control:RestrictedBox Type="Text" Value="{Binding Path=UserName,Mode=TwoWay}">
Thanks,
Imdadhusen

Error in Binding Custom Textbox Property

I have created custom Textbox in Silverlight 4, MVVM and PRISM 4. The custom text box has dynamic behavior link it dynamically set TextMode to either Password or Text.
This is working perfect. ( if i am bind TextMode static)
<control:PasswordTextBox x:Name="customTextBox2" Width="100" Height="30" Grid.Row="4" Grid.Column="1" Text="{Binding Email}" TextMode="Password"/>
This is giving me an error (if i am binding with dynamic)
<control:PasswordTextBox x:Name="customTextBox1" Width="100" Height="30" Grid.Row="4" Grid.Column="1" Text="{Binding Email}" TextMode="{Binding WritingMode}"/>
following is my ViewModel code
[Export]
[PartCreationPolicy(CreationPolicy.NonShared)]
public class UserRightsViewModel : NotificationObject, IRegionMemberLifetime
{
private Mode _writingMode = Mode.Text;
public Mode WritingMode
{
get { return _writingMode; }
set
{
_writingMode = value; RaisePropertyChanged("WritingMode");
}
}
[ImportingConstructor]
public UserRightsViewModel(IEventAggregator eventAggregator, IRegionManager regionManager)
{
UserSecurity security = new UserSecurity();
FormSecurity formSecurity = security.GetSecurityList("Admin");
formSecurity.WritingMode = Mode.Password;
}
}
following is the enum
namespace QSys.Library.Enums
{
public enum Mode
{
Text,
Password
}
}
following code for Custom PasswordTextBox
namespace QSys.Library.Controls
{
public partial class PasswordTextBox : TextBox
{
#region Variables
private string _Text = string.Empty;
private string _PasswordChar = "*";
private Mode _TextMode = Mode.Text;
#endregion
#region Properties
/// <summary>
/// The text associated with the control.
/// </summary>
public new string Text
{
get { return _Text; }
set
{
_Text = value;
DisplayMaskedCharacters();
}
}
/// <summary>
/// Indicates the character to display for password input.
/// </summary>
public string PasswordChar
{
get { return _PasswordChar; }
set { _PasswordChar = value; }
}
/// <summary>
/// Indicates the input text mode to display for either text or password.
/// </summary>
public Mode TextMode
{
get { return _TextMode; }
set { _TextMode = value; }
}
#endregion
#region Constructors
public PasswordTextBox()
{
this.TextChanged += new TextChangedEventHandler(PasswordTextBox_TextChanged);
this.KeyDown += new System.Windows.Input.KeyEventHandler(PasswordTextBox_KeyDown);
this.Loaded += new RoutedEventHandler(PasswordTextBox_Loaded);
}
#endregion
#region Event Handlers
void PasswordTextBox_Loaded(object sender, System.Windows.RoutedEventArgs e)
{
//this.TextChanged += ImmediateTextBox_TextChanged;
}
public void PasswordTextBox_TextChanged(object sender, TextChangedEventArgs e)
{
if (base.Text.Length >= _Text.Length) _Text += base.Text.Substring(_Text.Length);
DisplayMaskedCharacters();
}
public void PasswordTextBox_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
{
int cursorPosition = this.SelectionStart;
int selectionLength = this.SelectionLength;
// Handle Delete and Backspace Keys Appropriately
if (e.Key == System.Windows.Input.Key.Back || e.Key == System.Windows.Input.Key.Delete)
{
if (cursorPosition < _Text.Length)
_Text = _Text.Remove(cursorPosition, (selectionLength > 0 ? selectionLength : 1));
}
base.Text = _Text;
this.Select((cursorPosition > _Text.Length ? _Text.Length : cursorPosition), 0);
DisplayMaskedCharacters();
}
#endregion
#region Private Methods
private void DisplayMaskedCharacters()
{
int cursorPosition = this.SelectionStart;
// This changes the Text property of the base TextBox class to display all Asterisks in the control
base.Text = new string(_PasswordChar.ToCharArray()[0], _Text.Length);
this.Select((cursorPosition > _Text.Length ? _Text.Length : cursorPosition), 0);
}
#endregion
#region Public Methods
#endregion
}
}
I am getting following error if i am binding with dynamically.
Set property 'QSys.Library.Controls.PasswordTextBox.TextMode' threw an exception. [Line: 40 Position: 144]
Your answer would be appreciated.
Thanks in advance.
Imdadhusen
Try to change in your PasswordTextBox class
public Mode TextMode
{
get { return _TextMode; }
set { _TextMode = value; }
}
to
public static readonly DependencyProperty TextModeProperty =
DependencyProperty.Register("TextMode", typeof(Mode), typeof(PasswordTextBox), new PropertyMetadata(default(Mode)));
public Mode TextMode
{
get { return (Mode) GetValue(TextModeProperty); }
set { SetValue(TextModeProperty, value); }
}
You can read more here:
Dependency Properties Overview
DependencyProperty Class
The main paragraph from the second link is:
A DependencyProperty supports the following capabilities in Windows
Presentation Foundation (WPF):
....
The property can be set through data binding. For more information about data binding dependency properties, see How to: Bind the
Properties of Two Controls.
I provide links for WPF, but basically for Silverlight it's the same

Create custom control with nested tag like GridView >> Columns >> Paging

Expert,
I would like to create a custom control with following feature and this is successfully created:
<fv:Album Runat="Server" Id="WeddingAlbum" Width="600" Height="600" SkinColor="SkyBlue" AllowedFileExtensions="jpg|png|jpeg|gif" MessageDelay="6000"
SavePageUrl="saveupload.aspx" RemovePageUrl="removeupload.aspx"
ThumbnailHeight="150" Thumbnailwidth="150" ThumbnailFadeIn="slow" ThumbnailFadeOut="slow" ThumbnailShowDelete="true"
PopupView="true" PopupViewType="All" PopupOverlayShow="true" PopupTransitionIn="elastic" PopupTransitionOut="elastic"
</fv:Album>
but i would like to segregate Album with Thumbnail and Popup tag. it look like
<fv:Album Runat="Server" Id="WeddingAlbum" Width="600" Height="600" SkinColor="SkyBlue" AllowedFileExtensions="jpg|png|jpeg|gif" MessageDelay="6000" SavePageUrl="saveupload.aspx" RemovePageUrl="removeupload.aspx">
<fv:Thumbnail Height="150" width="150" FadeIn="slow" FadeOut="slow" ShowDelete="true" />
<fv:Popup View="true" ViewType="All" OverlayShow="true" TransitionIn="elastic" TransitionOut="elastic"/>
</fv:Album>
can any body tell me how can i achieve the above functionality?
Example:
<asp:GridView ID="productGridView" Runat="server" DataSourceID="productsDataSource"
<FooterStyle ForeColor="#8C4510" BackColor="#F7DFB5"></FooterStyle>
<PagerStyle ForeColor="#8C4510" HorizontalAlign="Center"></PagerStyle>
<HeaderStyle ForeColor="White" BackColor="#A55129"></HeaderStyle>
</asp:GridView>
Thanks in advance!
Imdadhusen
Album.cs
namespace Imdadhusen.Controls.Web
{
[DefaultProperty("Text")]
[ToolboxData("<{0}:Album runat=\"server\" />")]
[ToolboxBitmap(typeof(Album), "Album.bmp")]
public class Album : WebControl, IScriptControl
{
#region "Popup Properties"
private Popup _popup = new Popup();
//PersistenceMode.InnerProperty: Specifies that the property persists in
//the ASP.NET server control as a nested tag.
//DesignerSerializationVisibility.Content: Specifies that a visual
//designer serializes the contents of this property instead of the
//property itself.
[DefaultValue("")]
[Category("Custom")]
[PersistenceMode(PersistenceMode.InnerProperty)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public Popup Popup
{
get { return _popup; }
set { _popup = value; }
}
#endregion
#region "Popup Properties"
private Thumbnail _thumbnail = new Thumbnail();
[DefaultValue("")]
[Category("Custom")]
[PersistenceMode(PersistenceMode.InnerProperty)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public Thumbnail Thumbnail
{
get { return _thumbnail; }
set { _thumbnail = value; }
}
#endregion
#region "Control Properties"
public string UploadButtonID
{
get { return this.ViewState["UploadButtonID"] == null ? string.Empty : (string)this.ViewState["UploadButtonID"]; }
set { this.ViewState["UploadButtonID"] = value; }
}
/// <summary>
/// Location of the server-side upload script
/// </summary>
public string Action
{
get { return this.ViewState["Action"] == null ? string.Empty : (string)this.ViewState["Action"]; }
set { this.ViewState["Action"] = value; }
}
/// <summary>
/// Additional data to send
/// </summary>
public string ExtraData
{
get { return this.ViewState["ExtraData"] == null ? string.Empty : (string)this.ViewState["ExtraData"]; }
set { this.ViewState["ExtraData"] = value; }
}
/// <summary>
/// Callback to fire before file is uploaded
/// You can return false to cancel upload
/// </summary>
public string OnSubmitFunction
{
get { return this.ViewState["OnSubmitFunction"] == null ? string.Empty : (string)this.ViewState["OnSubmitFunction"]; }
set { this.ViewState["OnSubmitFunction"] = value; }
}
/// <summary>
/// Submit file as soon as it's selected
/// </summary>
public bool AutoSubmit
{
get { return this.ViewState["AutoSubmit"] == null ? true : (bool)this.ViewState["AutoSubmit"]; }
set { this.ViewState["AutoSubmit"] = value; }
}
/// <summary>
/// The type of data that you're expecting back from the server.
/// Html and xml are detected automatically.
/// Only useful when you are using json data as a response.
/// Set to "json" in that case.
/// </summary>
public string ResponseType
{
get { return this.ViewState["ResponseType"] == null ? string.Empty : (string)this.ViewState["ResponseType"]; }
set { this.ViewState["ResponseType"] = value; }
}
// When user selects a file, useful with autoSubmit disabled
public string OnChangeFunction
{
get { return this.ViewState["OnChangeFunction"] == null ? string.Empty : (string)this.ViewState["OnChangeFunction"]; }
set { this.ViewState["OnChangeFunction"] = value; }
}
/// <summary>
/// Fired when file upload is completed
/// WARNING! DO NOT USE "FALSE" STRING AS A RESPONSE!
/// </summary>
public string OnCompleteFunction
{
get { return this.ViewState["OnCompleteFunction"] == null ? string.Empty : (string)this.ViewState["OnCompleteFunction"]; }
set { this.ViewState["OnCompleteFunction"] = value; }
}
#endregion
#region "Page Events"
protected override void OnPreRender(EventArgs e)
{
if (!this.DesignMode)
{
//test for the existence of a ScriptManager
ScriptManager sMgr = ScriptManager.GetCurrent(Page);
if (sMgr == null)
throw new HttpException(
"A ScriptManager control must exist on the page.");
sMgr.RegisterScriptControl(this);
}
base.OnPreRender(e);
}
protected override void Render(HtmlTextWriter output)
{
Control btnUpload = this.NamingContainer.FindControl(this.UploadButtonID);
if (btnUpload == null) throw new HttpException("A UploadButtonID must point to an existing control on the page.");
StringBuilder startupscript = new StringBuilder();
startupscript.AppendLine("$().ready(function () {");
startupscript.AppendLine(" $(function () {");
startupscript.AppendFormat(" var btnUpload = $('#{0}');\n", btnUpload.ClientID);
startupscript.AppendLine(" new AjaxUpload(btnUpload, {");
startupscript.AppendFormat(" name: '{0}'", this.UniqueID);
if (!string.IsNullOrEmpty(this.OnChangeFunction))
startupscript.AppendFormat(",\n onChange: {0}", this.OnChangeFunction);
if (this.AutoSubmit)
{
startupscript.AppendFormat(",\n action: '{0}'", this.Action);
if (!string.IsNullOrEmpty(this.ResponseType))
startupscript.AppendFormat(",\n responseType: {0}", this.ResponseType);
if (!string.IsNullOrEmpty(this.OnSubmitFunction))
startupscript.AppendFormat(",\n onSubmit: {0}", this.OnSubmitFunction);
if (!string.IsNullOrEmpty(this.OnCompleteFunction))
startupscript.AppendFormat(",\n onComplete: {0}", this.OnCompleteFunction);
}
else
{
startupscript.Append(",\n autoSubmit: false");
}
startupscript.AppendLine("\n });");
startupscript.AppendLine(" });");
startupscript.AppendLine("});");
this.Page.ClientScript.RegisterStartupScript(this.GetType(), "startupscript", startupscript.ToString(), true);
base.Render(output);
}
#endregion
#region "IScriptControl Members"
IEnumerable<ScriptDescriptor> IScriptControl.GetScriptDescriptors()
{
return new ScriptDescriptor[] { };
}
IEnumerable<ScriptReference> IScriptControl.GetScriptReferences()
{
ScriptReference reference = new ScriptReference();
reference.Assembly = "PhotoAlbum";
reference.Name = "Imdadhusen.Controls.Web.Script.ajaxupload.3.5.js";
return new ScriptReference[] { reference };
}
#endregion
}
}
Popup.cs
namespace Imdadhusen.Controls.Web
{
/// <summary>
///ExpandableObjectConverter: Provides a type converter to convert expandable
///objects. It adds support for properties on an object to the methods and
///properties that TypeConverter provides.
/// </summary>
[TypeConverter(typeof(ExpandableObjectConverter))]
public class Popup
{
//View="true" ViewType="All" OverlayShow="true" TransitionIn="elastic" TransitionOut="elastic"
public Popup()
{
}
//start View
private bool _view;
[DefaultValue(true)]
[NotifyParentProperty(true)]
[RefreshProperties(RefreshProperties.Repaint)]
public bool View
{
get { return _view; }
set { _view = value; }
}
//end View
//start ViewType
private _ViewType _viewtype;
public enum _ViewType
{
All,
Single
}
[DefaultValue(_ViewType.All)]
[NotifyParentProperty(true)]
[RefreshProperties(RefreshProperties.Repaint)]
public _ViewType ViewType
{
get { return _viewtype; }
set { _viewtype = value; }
}
//end ViewType
//start ShowOverlay
private bool _overlayshow;
[DefaultValue(true)]
[NotifyParentProperty(true)]
[RefreshProperties(RefreshProperties.Repaint)]
public bool ShowOverlay
{
get { return _overlayshow; }
set { _overlayshow = value; }
}
//end ShowOverlay
//start TransitionIn
private _TransitionIn _transitionin;
public enum _TransitionIn
{
Elastic,
Fade,
None
}
[DefaultValue("")]
[NotifyParentProperty(true)]
[RefreshProperties(RefreshProperties.Repaint)]
public _TransitionIn TransitionIn
{
get { return _transitionin; }
set { _transitionin = value; }
}
//end TransitionIn
//start TransitionOut
private _TransitionOut _transitionout;
public enum _TransitionOut
{
Elastic,
Fade,
None
}
[DefaultValue(_TransitionOut.Elastic)]
[NotifyParentProperty(true)]
[RefreshProperties(RefreshProperties.Repaint)]
public _TransitionOut TransitionOut
{
get { return _transitionout; }
set { _transitionout = value; }
}
//end TransitionOut
}
}
Thumbnail.cs
namespace Imdadhusen.Controls.Web
{
/// <summary>
///ExpandableObjectConverter: Provides a type converter to convert expandable
///objects. It adds support for properties on an object to the methods and
///properties that TypeConverter provides.
/// </summary>
[TypeConverter(typeof(ExpandableObjectConverter))]
public class Thumbnail
{
//<fv:Thumbnail Height="150" width="150" FadeIn="slow" FadeOut="slow" ShowDelete="true" />
public Thumbnail()
{
}
//start Height
private int _height;
[DefaultValue(150)]
[NotifyParentProperty(true)]
[RefreshProperties(RefreshProperties.Repaint)]
public int Height
{
get { return _height; }
set { _height = value; }
}
//end Height
//start Width
private int _width;
[DefaultValue(150)]
[NotifyParentProperty(true)]
[RefreshProperties(RefreshProperties.Repaint)]
public int Width
{
get { return _width; }
set { _width = value; }
}
//end Width
//start FadeIn
private _FadeIn _fadein;
public enum _FadeIn
{
Slow,
Medium,
Fast
}
[DefaultValue(_FadeIn.Medium)]
[NotifyParentProperty(true)]
[RefreshProperties(RefreshProperties.Repaint)]
public _FadeIn FadeIn
{
get { return _fadein; }
set { _fadein = value; }
}
//end FadeIn
//start FadeOut
private _FadeOut _fadeout;
public enum _FadeOut
{
Slow,
Medium,
Fast
}
[DefaultValue(_FadeOut.Medium)]
[NotifyParentProperty(true)]
[RefreshProperties(RefreshProperties.Repaint)]
public _FadeOut FadeOut
{
get { return _fadeout; }
set { _fadeout = value; }
}
//end FadeOut
//start ShowDelete
private bool _showdelete;
[DefaultValue(true)]
[NotifyParentProperty(true)]
[RefreshProperties(RefreshProperties.Repaint)]
public bool ShowDelete
{
get { return _showdelete; }
set { _showdelete = value; }
}
//end View
}
}
Index.cshtml