本文整理汇总了C#中Windows.UI.Xaml.UIElement类的典型用法代码示例。如果您正苦于以下问题:C# UIElement类的具体用法?C# UIElement怎么用?C# UIElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UIElement类属于Windows.UI.Xaml命名空间,在下文中一共展示了UIElement类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: LostFocusHandler
private void LostFocusHandler(object sender, RoutedEventArgs e)
{
if (lastFocusedElement == (UIElement)sender)
{
lastFocusedElement = null;
}
}
开发者ID:oldnewthing,项目名称:old-Windows8-samples,代码行数:7,代码来源:InputPaneHelper.cs
示例2: OnApplyTemplate
/// <summary>
/// Invoked whenever application code or internal processes (such as a rebuilding layout pass) call ApplyTemplate.
/// In simplest terms, this means the method is called just before a UI element displays in your app.
/// Override this method to influence the default post-template logic of a class.
/// </summary>
protected override void OnApplyTemplate()
{
// Border
this.border = this.GetTemplateChild(BorderPartName) as Border;
if (this.border != null)
{
this.border.ManipulationStarted += Border_ManipulationStarted;
this.border.ManipulationDelta += Border_ManipulationDelta;
this.border.ManipulationCompleted += Border_ManipulationCompleted;
this.border.Tapped += Border_Tapped;
this.border.PointerEntered += Border_PointerEntered;
// Move Canvas properties from control to border.
Canvas.SetLeft(this.border, Canvas.GetLeft(this));
Canvas.SetLeft(this, 0);
Canvas.SetTop(this.border, Canvas.GetTop(this));
Canvas.SetTop(this, 0);
// Move Margin to border.
this.border.Padding = this.Margin;
this.Margin = new Thickness(0);
}
else
{
// Exception
throw new Exception("Floating Control Style has no Border.");
}
// Overlay
this.overlay = GetTemplateChild(OverlayPartName) as UIElement;
this.Loaded += Floating_Loaded;
}
开发者ID:XamlBrewer,项目名称:UWP-Floating-Content-Sample,代码行数:38,代码来源:FloatingContent.cs
示例3: ShowFlyout
/// <summary>
/// Shows a popup dialog for the specified model relative to the <paramref name="placementTarget"/>.
/// </summary>
/// <param name="rootModel">The root model.</param>
/// <param name="placementTarget">The placement target.</param>
/// <param name="viewSettings">The optional dialog settings.</param>
public void ShowFlyout(object rootModel, UIElement placementTarget, IDictionary<string, object> viewSettings = null) {
var view = ViewLocator.LocateForModel(rootModel, null, null);
ViewModelBinder.Bind(rootModel, view, null);
var flyout = new Flyout
{
Content = view,
PlacementTarget = placementTarget,
};
ApplySettings(flyout, viewSettings);
flyout.IsOpen = true;
var deactivator = rootModel as IDeactivate;
if (deactivator != null) {
EventHandler<object> closed = null;
closed = (s, e) => {
deactivator.Deactivate(true);
flyout.Closed -= closed;
};
flyout.Closed += closed;
}
var activator = rootModel as IActivate;
if (activator != null) {
activator.Activate();
}
}
开发者ID:Geminior,项目名称:Caliburn.Micro.Extras,代码行数:35,代码来源:CallistoWindowManager.cs
示例4: ManipulationInputProcessor
public ManipulationInputProcessor(Windows.UI.Input.GestureRecognizer gr, Windows.UI.Xaml.UIElement target, Windows.UI.Xaml.UIElement referenceframe)
{
this.gestureRecognizer = gr;
this.element = target;
this.reference = referenceframe;
this.gestureRecognizer.GestureSettings =
Windows.UI.Input.GestureSettings.Tap |
Windows.UI.Input.GestureSettings.Hold | //hold must be set in order to recognize the press & hold gesture
Windows.UI.Input.GestureSettings.RightTap |
Windows.UI.Input.GestureSettings.ManipulationTranslateX |
Windows.UI.Input.GestureSettings.ManipulationTranslateY |
Windows.UI.Input.GestureSettings.ManipulationRotate |
Windows.UI.Input.GestureSettings.ManipulationScale |
Windows.UI.Input.GestureSettings.ManipulationTranslateInertia |
Windows.UI.Input.GestureSettings.ManipulationRotateInertia |
Windows.UI.Input.GestureSettings.ManipulationMultipleFingerPanning | //reduces zoom jitter when panning with multiple fingers
Windows.UI.Input.GestureSettings.ManipulationScaleInertia;
// Set up pointer event handlers. These receive input events that are used by the gesture recognizer.
this.element.PointerCanceled += OnPointerCanceled;
this.element.PointerPressed += OnPointerPressed;
this.element.PointerReleased += OnPointerReleased;
this.element.PointerMoved += OnPointerMoved;
// Set up event handlers to respond to gesture recognizer output
this.gestureRecognizer.Tapped += OnTapped;
this.gestureRecognizer.RightTapped += OnRightTapped;
this.gestureRecognizer.ManipulationStarted += OnManipulationStarted;
this.gestureRecognizer.ManipulationUpdated += OnManipulationUpdated;
this.gestureRecognizer.ManipulationCompleted += OnManipulationCompleted;
InitializeTransforms();
}
开发者ID:mbin,项目名称:Win81App,代码行数:33,代码来源:S2-Manipulations.xaml.cs
示例5: CaptureAndSave
async System.Threading.Tasks.Task<Windows.Storage.StorageFile> CaptureAndSave(UIElement element)
{
// capture
var bitmap = new Windows.UI.Xaml.Media.Imaging.RenderTargetBitmap();
await bitmap.RenderAsync(element);
var picker = new Windows.Storage.Pickers.FileSavePicker
{
SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary,
FileTypeChoices = { { "JPEG", new[] { ".jpg" } } },
SuggestedFileName = "Image",
DefaultFileExtension = ".jpg",
CommitButtonText = "Save",
};
// save
var file = await picker.PickSaveFileAsync();
using (var stream = await file.OpenStreamForWriteAsync())
{
var pixel = await bitmap.GetPixelsAsync();
var dpi = Windows.Graphics.Display.DisplayInformation.GetForCurrentView().LogicalDpi;
var random = stream.AsRandomAccessStream();
var jpg = Windows.Graphics.Imaging.BitmapEncoder.JpegEncoderId;
var encoder = await Windows.Graphics.Imaging.BitmapEncoder.CreateAsync(jpg, random);
var format = Windows.Graphics.Imaging.BitmapPixelFormat.Bgra8;
var alpha = Windows.Graphics.Imaging.BitmapAlphaMode.Ignore;
var width = (uint)bitmap.PixelWidth;
var height = (uint)bitmap.PixelHeight;
encoder.SetPixelData(format, alpha, width, height, dpi, dpi, pixel.ToArray());
await encoder.FlushAsync();
}
return file;
}
开发者ID:noriike,项目名称:xaml-106136,代码行数:33,代码来源:MainPage.xaml.cs
示例6: RenderToBase64
public async Task<string> RenderToBase64(UIElement element)
{
RenderTargetBitmap rtb = new RenderTargetBitmap();
await rtb.RenderAsync(element);
var pixelBuffer = await rtb.GetPixelsAsync();
var pixels = pixelBuffer.ToArray();
// Useful for rendering in the correct DPI
var displayInformation = DisplayInformation.GetForCurrentView();
var stream = new InMemoryRandomAccessStream();
var encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.PngEncoderId, stream);
encoder.SetPixelData(BitmapPixelFormat.Bgra8,
BitmapAlphaMode.Premultiplied,
(uint)rtb.PixelWidth,
(uint)rtb.PixelHeight,
displayInformation.RawDpiX,
displayInformation.RawDpiY,
pixels);
await encoder.FlushAsync();
stream.Seek(0);
// read bytes
var bytes = new byte[stream.Size];
await stream.AsStream().ReadAsync(bytes, 0, bytes.Length);
// create base64
return Convert.ToBase64String(bytes);
}
开发者ID:dachibox,项目名称:UWP-Samples,代码行数:31,代码来源:MainViewModel.cs
示例7: RunIfSelected
private void RunIfSelected(UIElement element, Action action)
{
if (ChartsList.SelectedItem == element)
{
action.Invoke();
}
}
开发者ID:xyzzer,项目名称:WinRTXamlToolkit,代码行数:7,代码来源:ChartTestView.xaml.cs
示例8: AdnGestureManager
public AdnGestureManager(
UIElement window,
AdnRenderer renderer)
{
_window = window;
_renderer = renderer;
_pointerMode = PointerMode.kIdleMode;
_accumulator = new ValueAccumulator(
-30.0 * 1000.0 / 5.0,
-100.0 * 1000.0 / 5.0,
-5.0 * 1000.0 / 5.0);
_pointers = new Dictionary<uint, PointerPoint>();
window.PointerMoved += OnPointerMoved;
window.PointerPressed += OnPointerPressed;
window.PointerReleased += OnPointerReleased;
window.PointerWheelChanged += OnPointerWheelChanged;
_gr = new GestureRecognizer();
_gr.GestureSettings =
GestureSettings.Tap |
GestureSettings.Drag |
GestureSettings.DoubleTap |
GestureSettings.ManipulationScale;
_gr.Tapped += OnTapped;
_gr.ManipulationStarted += OnManipulationStarted;
_gr.ManipulationUpdated += OnManipulationUpdated;
_gr.ManipulationCompleted += OnManipulationCompleted;
}
开发者ID:DevNullx64,项目名称:ADN-WinRT-Samples,代码行数:35,代码来源:AdnGestureManager.cs
示例9: ShowMessage
// Unused and untested
public static void ShowMessage(string message, UIElement placementTarget, PlacementMode placementMode=PlacementMode.Top)
{
var f = new Callisto.Controls.Flyout();
var b = new Border()
{
Width = 300,
Height = 125
};
TextBlock tb = new TextBlock();
tb.HorizontalAlignment = HorizontalAlignment.Center;
tb.VerticalAlignment = VerticalAlignment.Center;
tb.TextWrapping = TextWrapping.Wrap;
tb.FontSize = 12f;
tb.Text = message;
b.Child = tb;
f.Content = b;
f.Placement = placementMode;
f.PlacementTarget = placementTarget;
f.IsOpen = true;
}
开发者ID:christophwille,项目名称:Sprudelsuche,代码行数:27,代码来源:MessageService.cs
示例10: Initialize
public void Initialize(UIElement host, CompositionImage sourceElement, object payload)
{
_host = host;
_parent = host;
_payload = payload;
// Make a copy of the sourceElement's sprite so we can hand it off to the next page
SpriteVisual sourceSprite = sourceElement.SpriteVisual;
Compositor compositor = sourceSprite.Compositor;
_sprite = compositor.CreateSpriteVisual();
_sprite.Size = sourceSprite.Size;
_sprite.Brush = sourceElement.SurfaceBrush;
// We're going to use the backing surface, make sure it doesn't get released
sourceElement.SharedSurface = true;
// Determine the offset from the host to the source element used in the transition
GeneralTransform coordinate = sourceElement.TransformToVisual(_parent);
Point position = coordinate.TransformPoint(new Point(0, 0));
// Set the sprite to that offset relative to the host
_sprite.Offset = new Vector3((float)position.X, (float)position.Y, 0);
// Set the sprite as the content under the host
ElementCompositionPreview.SetElementChildVisual(_parent, _sprite);
}
开发者ID:chenjianwp,项目名称:WindowsUIDevLabs,代码行数:26,代码来源:ConnectedTransition.cs
示例11: SetPrintContent
public virtual void SetPrintContent(UIElement content)
{
if (content == null)
return;
PrintContent = content;
}
开发者ID:dimkname,项目名称:UAP-Samples,代码行数:7,代码来源:PrintService.cs
示例12: GetVisual
public static ContainerVisual GetVisual(UIElement element)
{
var hostVisual = ElementCompositionPreview.GetElementVisual(element);
ContainerVisual root = hostVisual.Compositor.CreateContainerVisual();
ElementCompositionPreview.SetElementChildVisual(element, root);
return root;
}
开发者ID:juanpaexpedite,项目名称:Universal,代码行数:7,代码来源:CompositionManager.cs
示例13: SetUpDeviceScenarios
/// <summary>
/// Displays the compatible scenarios and hides the non-compatible ones.
/// If there are no supported devices, the scenarioContainer will be hidden and an error message
/// will be displayed.
/// </summary>
/// <param name="scenarios">The key is the device type that the value, scenario, supports.</param>
/// <param name="scenarioContainer">The container that encompasses all the scenarios that are specific to devices</param>
public static void SetUpDeviceScenarios(Dictionary<DeviceType, UIElement> scenarios, UIElement scenarioContainer)
{
UIElement supportedScenario = null;
if (EventHandlerForDevice.Current.IsDeviceConnected)
{
foreach (KeyValuePair<DeviceType, UIElement> deviceScenario in scenarios)
{
// Enable the scenario if it's generic or the device type matches
if ((deviceScenario.Key == DeviceType.All)
|| (deviceScenario.Key == Utilities.GetDeviceType(EventHandlerForDevice.Current.Device)))
{
// Make the scenario visible in case other devices use the same scenario and collapsed it.
deviceScenario.Value.Visibility = Visibility.Visible;
supportedScenario = deviceScenario.Value;
}
else if (deviceScenario.Value != supportedScenario)
{
// Don't hide the scenario if it is supported by the current device and is shared by other devices
deviceScenario.Value.Visibility = Visibility.Collapsed;
}
}
}
if (supportedScenario == null)
{
// Hide the container so that common elements shared across scenarios are also hidden
scenarioContainer.Visibility = Visibility.Collapsed;
NotifyDeviceNotConnected();
}
}
开发者ID:mbin,项目名称:Win81App,代码行数:41,代码来源:Utilities.cs
示例14: Add
public virtual void Add(UIElement control)
{
int rows = _grid.RowDefinitions.Count;
_grid.RowDefinitions.Add(new RowDefinition());
var textBlock = new TextBlock
{
Text = ListItemPrefix,
Margin = new Thickness(0, 5, 0, 5),
HorizontalAlignment = HorizontalAlignment.Center
};
Grid.SetColumn(textBlock, 0);
Grid.SetRow(textBlock, rows);
_grid.Children.Add(textBlock);
if ((control is FrameworkElement) == false)
{
// UIElement can set column and row,
// so use a border.
var border = new Border
{
Child = control
};
control = border;
}
Grid.SetColumn((FrameworkElement)control, 1);
Grid.SetRow((FrameworkElement)control, rows);
_grid.Children.Add(control);
}
开发者ID:sahirmemon,项目名称:SoftwareKobo.HtmlRender,代码行数:29,代码来源:ListContainer.cs
示例15: InputEvents
public InputEvents(CoreWindow window, UIElement inputElement, TouchQueue touchQueue)
{
_touchQueue = touchQueue;
// The key events are always tied to the window as those will
// only arrive here if some other control hasn't gotten it.
window.KeyDown += CoreWindow_KeyDown;
window.KeyUp += CoreWindow_KeyUp;
window.VisibilityChanged += CoreWindow_VisibilityChanged;
if (inputElement != null)
{
// If we have an input UIElement then we bind input events
// to it else we'll get events for overlapping XAML controls.
inputElement.PointerPressed += UIElement_PointerPressed;
inputElement.PointerReleased += UIElement_PointerReleased;
inputElement.PointerCanceled += UIElement_PointerReleased;
inputElement.PointerMoved += UIElement_PointerMoved;
inputElement.PointerWheelChanged += UIElement_PointerWheelChanged;
}
else
{
// If we only have a CoreWindow then use it for input events.
window.PointerPressed += CoreWindow_PointerPressed;
window.PointerReleased += CoreWindow_PointerReleased;
window.PointerMoved += CoreWindow_PointerMoved;
window.PointerWheelChanged += CoreWindow_PointerWheelChanged;
}
}
开发者ID:BrainSlugs83,项目名称:MonoGame,代码行数:29,代码来源:InputEvents.cs
示例16: DistanceFromTop
public static double DistanceFromTop(this ScrollViewer scrollViewer, UIElement element)
{
var transform = element.TransformToVisual(scrollViewer);
var position = transform.TransformPoint(new Point(0, 0));
return position.Y;
}
开发者ID:JustinXinLiu,项目名称:Parallax,代码行数:7,代码来源:Extensions.cs
示例17: OnPointerPressed
public static void OnPointerPressed(UIElement sender, TouchSliderC slider, PointerRoutedEventArgs e)
{
sender.CapturePointer(e.Pointer);
_lastPoint = e.GetCurrentPoint(slider);
_isDragActive = true;
e.Handled = true;
}
开发者ID:Mordrag,项目名称:X-Air-Universal,代码行数:7,代码来源:TouchSliderCDragValueHandler.cs
示例18: InjectPropertiesForChildViews
private void InjectPropertiesForChildViews(IComponentContext context, IPresentationBusConfiguration bus, UIElement uiElement)
{
var userControl = uiElement as UserControl;
if (userControl != null)
{
InjectProperties(context, bus, userControl.Content);
return;
}
var panel = uiElement as Panel;
if (panel != null)
{
foreach (var child in panel.Children)
{
InjectProperties(context, bus, child);
}
return;
}
var contentControl = uiElement as ContentControl;
if (contentControl != null)
{
InjectProperties(context, bus, contentControl.Content as UIElement);
return;
}
}
开发者ID:slewis74,项目名称:Jukebox,代码行数:26,代码来源:ViewModule.cs
示例19: Add
public void Add(UIElement control)
{
Add(new InlineUIContainer
{
Child = control
});
}
开发者ID:sahirmemon,项目名称:SoftwareKobo.HtmlRender,代码行数:7,代码来源:SpanContainer.cs
示例20: SetContent
public static void SetContent(this Popup popup, UIElement newContent)
{
var contentControl = popup.Child as ContentControl;
contentControl.Height = Window.Current.Bounds.Height;
contentControl.Width = Window.Current.Bounds.Width;
contentControl.Content = newContent;
}
开发者ID:Rasetech,项目名称:Template10,代码行数:7,代码来源:PopupService.cs
注:本文中的Windows.UI.Xaml.UIElement类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论