xaml

Windows Phone笔记(12)XAML基础知识

霸气de小男生 提交于 2020-03-07 13:29:43
1.XAML概述   在前面的笔记中我们都是使用 Silverlight for Windows Phone框架来开发Windows Phone 应用程序,其中我们使用 XMAL(可扩展应用程序标记语言 ) 来描述应用程序的UI,通过在第一篇笔记中我们对XAML进行了简单的介绍,我们知道:XAML是微软为构建应用程序用户界面而创建的一种新的 声明性 语言(关于声明性具体来说就是: XAML 可以通过使用一种语言结构来显示多个对象之间的分层关系,并使用一种后备类型约定来支持类型扩展,以初始化对象并设置对象的属性. ),基于并完全兼容XML。我们在常规的基于Silverlight的Windows Phone应用开发过程中: 使用声明性 XAML 标记构建可见用户界面 (UI) 元素, 使用后台代码用来响应和处理所有用户输入及所有由控件产生的事件。 这和我们在.NET开发中常见的开发模型类似,很好的将程序的后台逻辑和用户界面的代码分离,方便了开发过程中UI设计人员的开发人员的相互协作。XAML的语法基于XML,所有只要开发人员具有相应的编程基础就可以很快的掌握这门语言,但是XAML既然是在XML的基础上拓展的一门新的声明性语言,肯定也有它的不同的地方,这也是我们在学习过程中特别需要注意。 2.使用代码创建UI元素   使用XMAL标记构建可见的界面(UI)元素并不是我们唯一的选择

Keep LinearLayout at the bottom of screen

十年热恋 提交于 2020-03-06 10:03:16
问题 I know this question is asked a lot, because I was trying a lot of examples posted in here, but I just Can't make it work, this is what I have: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cardview="http://schemas.android.com/apk/res-auto" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center_horizontal" android:background="#3F51B5" android:padding=

Change gridViewItem's background color after first and second click on it

江枫思渺然 提交于 2020-03-06 04:54:12
问题 My point is to change gridViewItem's background color to Blue after first click and to Red after second click on it, then Blue, then Red ... Here is my c# code but it threw an exception 'System.NullReferenceException' on "gvi.Background = new SolidColorBrush(Windows.UI.Colors.Blue);": private void GridViewItem_Click (Object sender, ItemClickEventArgs e) { if(e!=null) { for (int numberOfClick= 1; numberOfClick <100; ++numberOfClick) { GridViewItem gvi = (GridViewItem)NameOf_ItemClick

WPF - How could I get a scrollviewer control from my XAML file in C#?

你离开我真会死。 提交于 2020-03-06 02:34:08
问题 I need to get a specific ScrollViewer control from an XAML file in C#, so that I can try to implement a drag-and-scroll system where when an item is dragged near the edge it will scroll accordingly. But I need access to all the methods to do this, yet I cannot find any info as to how to get the specific scrollviewer from the XAML. I need access to it from a separate .cs file in which most of the project's converters and functions are located. Not sure bout the downvotes tho seeing as I did

Win10 UWP xaml 延迟加载元素

北战南征 提交于 2020-03-06 00:11:45
xaml新增 x:DeferLoadStrategy 里面只有 Lazy ,查询了百度看到MSP_甄心cherish大神说的 xaml使用 x:DeferLoadStrategy="Lazy" 延迟加载元素 我写了代码 <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <Grid.RowDefinitions> <RowDefinition/> <RowDefinition/> <RowDefinition Height="auto"/> </Grid.RowDefinitions> <Image x:Name="ximg1" Source="/assets/1.jpg" Grid.Row="0" Margin="10,10,10,10"/> <Image x:Name="ximg2" Source="/assets/2.jpg" Grid.Row="1" Margin="10,10,10,10" x:DeferLoadStrategy="Lazy"/> <Button Content="显示" Grid.Row="2" Margin="10,10,10,10" HorizontalAlignment="Right" Click="Button_Click"/> </Grid>

Win10 UWP xaml 延迟加载元素

陌路散爱 提交于 2020-03-06 00:11:14
原文: Win10 UWP xaml 延迟加载元素 xaml新增 x:DeferLoadStrategy 里面只有 Lazy ,查询了百度看到MSP_甄心cherish大神说的 xaml使用 x:DeferLoadStrategy="Lazy" 延迟加载元素 我写了代码 <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <Grid.RowDefinitions> <RowDefinition/> <RowDefinition/> <RowDefinition Height="auto"/> </Grid.RowDefinitions> <Image x:Name="ximg1" Source="/assets/1.jpg" Grid.Row="0" Margin="10,10,10,10"/> <Image x:Name="ximg2" Source="/assets/2.jpg" Grid.Row="1" Margin="10,10,10,10" x:DeferLoadStrategy="Lazy"/> <Button Content="显示" Grid.Row="2" Margin="10,10,10,10" HorizontalAlignment="Right" Click=

了解 Xamarin.Forms 创建移动应用程序的基础知识 1 - StackLayout

℡╲_俬逩灬. 提交于 2020-03-05 15:38:13
简介 在 XAML 中创建 Xamarin.Forms StackLayout。 指定 StackLayout 的方向。 控制 StackLayout 内子视图的对齐和扩展。 使用 Visual Studio 2019 创建 StackLayout,演示如何在 StackLayout 中对齐控件。 创建 stacklayout 打开已有项目 AwesomeApp。 添加新项 StackLayoutPage.xaml: 编辑 StackLayoutPage.xaml: < StackLayout > < Label Text = " 第一个Label。 " /> < Label Text = " 第二个Label。 " /> < Label Text = " 第三个Label。 " /> </ StackLayout > StackLayout 默认为垂直方向。 此外,Margin 属性表示 ContentPage 中 StackLayout 的外边距。 * 除 Margin 外,StackLayout 还可设置 Padding 和 Spacing。 Padding 指定 StackLayout 的内边距,Spacing 指定 StackLayout 中每个子元素之间的间隔大小。 编辑 App.xaml.cs: public App ( ) { InitializeComponent

Bind to property in App.xaml

痴心易碎 提交于 2020-03-05 12:21:49
问题 I have a quick question: I want to bind a Solidcolorbrush, which is located in App.xaml's Resources. It has a key assigned to it, but how would I bind to that property from another page? Here is the App.xaml itself: <Application x:Class="Mplayer.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="MainWindow.xaml"> <Application.Resources> <ResourceDictionary> <Color x:Key="PrimaryAccentColor" A="255" R="3" G=

Bind to property in App.xaml

最后都变了- 提交于 2020-03-05 12:19:30
问题 I have a quick question: I want to bind a Solidcolorbrush, which is located in App.xaml's Resources. It has a key assigned to it, but how would I bind to that property from another page? Here is the App.xaml itself: <Application x:Class="Mplayer.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="MainWindow.xaml"> <Application.Resources> <ResourceDictionary> <Color x:Key="PrimaryAccentColor" A="255" R="3" G=

TreeView with MasterDetails and ToggleButton

本秂侑毒 提交于 2020-03-05 06:49:27
问题 I want to create a TreeView with MasterDetails on selected Item. The problem is, that no children are displayed in my SelectedItem, even when the parent is expanded. Somehow the HierarchicalDataTemplate seems to get lost. Maybe I am just wrong with the HierarchicalDataTemplate in the <TreeView.ItemTemplate> . Should I start with ItemsPanelTemplate or something similar? Have no clue at the moment. Here is my XAML: <Window x:Class="TreeViewMasterDetails.MainWindow" xmlns="http://schemas