本文整理汇总了C#中System.Windows.FrameworkElement类的典型用法代码示例。如果您正苦于以下问题:C# FrameworkElement类的具体用法?C# FrameworkElement怎么用?C# FrameworkElement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FrameworkElement类属于System.Windows命名空间,在下文中一共展示了FrameworkElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddAdorner
internal void AddAdorner(
AdornerLayer treeViewAdornerLayer, FrameworkElement adornedElement, ExplorerEFElement explorerElement,
ExplorerFrame explorerFrame)
{
var adornerY = GetAdornerY(adornedElement, explorerElement, explorerFrame);
if (adornerY >= 0)
{
SearchTickAdorner adorner;
if (!_adorners.TryGetValue(adornerY, out adorner))
{
adorner = new SearchTickAdorner(adornerY, adornedElement);
_adorners[adornerY] = adorner;
treeViewAdornerLayer.Add(adorner);
// adding adorners in batches of 100 - see bug: Windows OS Bugs 1750717
if ((_adorners.Count % 100) == 0)
{
treeViewAdornerLayer.UpdateLayout();
}
}
adorner.AddExplorerElement(explorerElement);
}
}
示例2: ShowChildWindow
public void ShowChildWindow(FrameworkElement content)
{
XmlContent = content;
OnPropertyChanged("XmlContent");
WindowVisibility = Visibility.Visible;
OnPropertyChanged("WindowVisibility");
}
示例3: UIAdorner
public UIAdorner(FrameworkElement adornee, FrameworkElement content)
: base(adornee)
{
this.adornee = adornee;
this.content = content;
AddVisualChild(this.content);
}
示例4: OnLoaded
public void OnLoaded(object sender, EventArgs e)
{
// Enable moving the window when clicking on the control CtlMoveable
this.CtlMoveable = (FrameworkElement)this.Template.FindName("CtlMoveable", this);
if (null != this.CtlMoveable)
{
this.CtlMoveable.MouseLeftButtonDown += new MouseButtonEventHandler(OnMoveableClick);
}
Application.Current.MainWindow = this;
// Disable Minimize and close buttons
var BtnClose = (FrameworkElement)this.Template.FindName("BtnClose", this);
if (BtnClose != null)
BtnClose.Visibility = System.Windows.Visibility.Hidden;
var BtnMinimize = (FrameworkElement)this.Template.FindName("BtnMinimize", this);
if (BtnMinimize != null)
BtnMinimize.Visibility = System.Windows.Visibility.Hidden;
// Check for updates async
// and register an event to catch its answer
vm.LoadApplicationData();
vm.SelfUpdaterApp.PropertyChanged += vm_PropertyChanged;
vm.UpdateSelfUpdaterAsync();
CtlProgress.Maximum = 1;
}
示例5: SetUpdateBindingOnChange
public static void SetUpdateBindingOnChange(FrameworkElement element, bool value)
{
Action<TextBox, bool> action = (txtBox, updateValue) =>
{
if (GetUpdateBindingOnChange(txtBox) == updateValue) return;
if (updateValue)
{
txtBox.TextChanged += element_TextChanged;
}
else
{
txtBox.TextChanged -= element_TextChanged;
}
txtBox.SetValue(UpdateBindingOnChangeProperty, updateValue);
};
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
if (element is TextBox)
{
action.Invoke(element as TextBox, value);
return;
}
element.GetChildrens<TextBox>().ForEach(i => action.Invoke(i, value));
});
}
示例6: Detach
public void Detach(FrameworkElement element)
{
element.MouseMove -= MouseMoveHandler;
element.MouseRightButtonDown -= MouseDownHandler;
element.MouseRightButtonUp -= MouseUpHandler;
element.MouseWheel -= OnMouseWheel;
}
示例7: StateWellDefined
public static bool StateWellDefined(FrameworkElement element, string stateName, bool prefixControlName = false)
{
string state = string.IsNullOrWhiteSpace(stateName) ? null : (prefixControlName ? element.Name + "_" +
stateName : stateName);
// Look for the visual state on the first child object. This is generally where states are declared
// when they are part of a ControlTemplate.
FrameworkElement child = null;
if (VisualTreeHelper.GetChildrenCount(element) > 0)
child = VisualTreeHelper.GetChild(element, 0) as FrameworkElement;
if (child == null)
return false;
var vsgs = VisualStateManager.GetVisualStateGroups(child);
if (vsgs != null && vsgs.Count > 0)
{
foreach (VisualStateGroup vsg in vsgs)
{
if (vsg.States != null)
{
foreach (VisualState vs in vsg.States)
{
if (vs.Name == state)
return true;
}
}
}
}
return false;
}
示例8: IsMouseOver
/// <summary>
/// Return wheter the mouse is over a control
/// </summary>
/// <param name="s"></param>
/// <param name="e"></param>
/// <returns>True if the mouse is over a control, false otherwise</returns>
internal static bool IsMouseOver(FrameworkElement s, System.Windows.Input.MouseEventArgs e)
{
Rect bounds = new Rect(0, 0, s.ActualWidth, s.ActualHeight);
if (bounds.Contains(e.GetPosition(s)))
return true;
return false;
}
示例9: SetupTargetBinding
public void SetupTargetBinding(FrameworkElement targetObject)
{
if (targetObject == null)
{
return;
}
// Prevent the designer from reporting exceptions since
// changes will be made of a Binding in use if it is set
if (DesignerProperties.GetIsInDesignMode(this) == true)
return;
// Bind to the selected TargetProperty, e.g. ActualHeight and get
// notified about changes in OnTargetPropertyListenerChanged
var listenerBinding = new Binding
{
Source = targetObject,
Path = new PropertyPath(TargetProperty),
Mode = BindingMode.OneWay
};
BindingOperations.SetBinding(this, TargetPropertyListenerProperty, listenerBinding);
// Set up a OneWayToSource Binding with the Binding declared in Xaml from
// the Mirror property of this class. The mirror property will be updated
// everytime the Listener property gets updated
BindingOperations.SetBinding(this, TargetPropertyMirrorProperty, Binding);
TargetPropertyValueChanged();
}
示例10: CreateBlockBox
public static Border CreateBlockBox(FrameworkElement child, double width, double height, double x, double y, Color backgroundColor)
{
var border = new Border()
{
BorderThickness = new Thickness(1, 1, 1, 1),
BorderBrush = Brushes.Silver,
Background = new SolidColorBrush(backgroundColor),
Width = width,
Height = height,
Margin = new Thickness(x, y, 0, 0),
Child = child
};
border.MouseEnter += (s, e) =>
{
border.Width = Math.Max(width, child.ActualWidth);
border.Height = Math.Max(height, child.ActualHeight);
Panel parent = (Panel)border.Parent;
border.TopMost();
};
border.MouseLeave += (s, e) =>
{
border.Width = width;
border.Height = height;
};
return border;
}
示例11: CloseExists
public void CloseExists()
{
CreateContainerWithRealMessageBus();
var title = Guid.NewGuid().ToString();
var viewModel = Substitute.For<ITitledViewModel>();
viewModel.Title.Returns(title);
var view = new FrameworkElement();
view.DataContext = viewModel;
var viewTarget = ViewTargets.DefaultView;
var viewResult = new ViewResult(view, viewTarget);
var viewBuilder = Substitute.For<IViewFactory>();
viewBuilder.Build(Arg.Any<ViewTargets>(), Arg.Any<Object>())
.Returns(viewResult);
ComponentContainer.Container.Register(Component.For<IViewFactory>().Instance(viewBuilder));
var window = new Window();
var tabControl = new TabControl();
var viewController = new ViewPlacer(window, tabControl);
var newTabItem = new TabItem() { Header = title };
tabControl.Items.Add(newTabItem);
var message = new CloseViewMessage(title);
_MessageBus.Publish<CloseViewMessage>(message);
Assert.AreEqual(0, tabControl.Items.Count);
}
示例12: ModifyNewContent
protected override FrameworkElement ModifyNewContent(ITransitionControl container, FrameworkElement newContent)
{
if (newContent == null)
{
HideBackground(container);
container.Remove(_border);
return null;
}
ShowBackground(container);
_border = WrapInBorder(newContent);
_border.Opacity = 0;
SetPosition(_border);
newContent.SizeChanged += (sender, e) => SetPosition(_border);
var ctrl = container.AsControl();
ctrl.SizeChanged += (sender, e) => SetPosition(_border);
return _border;
}
示例13: Bind
public static void Bind(FrameworkElement view, object viewModel)
{
Log.Info($"Binding '{view}' to '{viewModel}'");
var namedElements = UIHelper.FindNamedChildren(view);
var viewModelProperties = viewModel.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);
var matches = namedElements.Join(viewModelProperties, e => e.Name, p => p.Name, (e, p) => new { e, p });
foreach (var element in namedElements)
{
var matchingProperty = viewModelProperties.Where(p => p.Name == element.Name).SingleOrDefault();
if (matchingProperty == null)
{
Log.Debug($"No matching property for element '{element.Name}'");
continue;
}
if (!TryBind(element, matchingProperty, viewModel))
Log.Debug($"Could not bind element '{element.Name}' to property '{matchingProperty.Name}'");
}
view.DataContext = viewModel;
var viewAware = viewModel as IViewAware;
viewAware?.AttachView(view);
}
示例14: Show
public void Show(FrameworkElement popupContent)
{
_PopupContent = popupContent;
_Popup = new Popup();
_Popup.Child = this;
_Popup.IsOpen = true;
}
示例15: VoteVisible
public static void VoteVisible(FrameworkElement fe)
{
foreach (var item in fe.LogicalParents().TakeWhile(a => GetAutoHide(a) != AutoHide.Visible))
{
SetAutoHide(item, AutoHide.Visible);
}
}