我知道很少Xaml/WPF.我正在尝试Style在Windows 8 metro应用程序中设计一个Button具有洋红色背景的自定义,并且在按下时,具有蓝色背景.我知道我需要使用VisualStateManager但我找不到任何在线对任何人有意义的东西对这个问题知之甚少.有很多假设的知识.这是我到目前为止所得到的:
<Style x:Name="test" TargetType="Button">
<Setter Property="Background" Value="Magenta"/>
<Setter Property="Content" Value="Test style" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Pressed">
<Storyboard>
<turn the background blue>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Run Code Online (Sandbox Code Playgroud)
这段代码可能是非常错误的,但正如我所说,我一直试图修补一些我不理解的信息以创造结果.
感谢您的时间
我想在UWP中自动突出显示网址,电子邮件和电话号码.它可能在Android中,但似乎微软已经忘记了这个功能.在我的用例中,我从Web服务获取文本,因此我不知道文本格式是Web平台上的用户文本输入.
使用引导程序时我无法打开汉堡包菜单。有人能告诉我代码有什么问题吗?
我直接从引导程序网站上提取了代码。我看过其他人关于这个问题的问题,但建议的解决方案没有帮助。
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
<nav class="navbar fixed-top navbar-expand-lg navbar-light" style="background-color: #ffffff;">
<a class="navbar-brand" href="index.html">
<img src="logo.png" width="200" height="200" class="d-inline-block align-top" alt="">
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="index.html">Home <span class="sr-only">
(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="portfolio.html">Portfolio </a>
</li>
<li class="nav-item">
<a class="nav-link" href="about.html">About </a>
</li>
<li class="nav-item">
<a class="nav-link" href="contact.html">Contact </a>
</li>
</ul>
</div>
<div class="collapse navbar-collapse" id="navbarNavAltMarkup"> …Run Code Online (Sandbox Code Playgroud)我试图在表格单元格上方放置一个按钮,这是我所实现的:
这是代码:
body {
margin: 100px;
}
td {
border: 1px solid black;
padding: 20px;
text-align: center;
vertical-align: middle;
}
td span {
text-align: center;
}
table {
border-collapse: collapse;
}
#btn {
display: block;
margin-left: auto;
margin-right: auto;
position: relative;
height: 20px;
top: -30px;
}Run Code Online (Sandbox Code Playgroud)
<table>
<tr>
<td>
<button id='btn'>test</button>
<span>Alfreds Futterkiste</span>
</td>
<td>Maria Anders</td>
<td>Germany</td>
</tr>
<tr>
<td>Centro comercial Moctezuma</td>
<td>Francisco Chang</td>
<td>Mexico</td>
</tr>
</table>Run Code Online (Sandbox Code Playgroud)
看起来不错,我已将按钮放置在表格单元格上方。但有一件事困扰着我:第一个表格单元格中的文本没有垂直对齐。为什么?我用过vertical-align但是没效果。如何让它发挥作用
问题:我有一个新制作的UserControl,在父网格中带有几个telerik控件,可以在整个解决方案中使用它。听起来很简单吧?我创建了UserControl,我们将其称为My.Project.Controls.Tool类,然后尝试使用名称空间调用另一个View,xmlns:Controls="clr-namespace:My.Project.Controls;assembly=My.Project.GlobalUserControlDump"然后通过方便的dandy intellisense中轻松选择的名称在视图中进行设置。
正如预期的那样,我的UserControl出现在设计器的单独视图中就好了。因此,我采取了下一步的常规步骤,并进行了构建。...构建完成后(它运行正常,没有报告预期的错误),小虫子消失了!xaml当然仍然在View上,但是它从设计器中消失了,并且没有出现在内置解决方案上吗?
困惑,我回头,对UserControl进行快速更改,它又出现在设计器中。好的,我认为这一定是偶然的,所以我再次构建它。...然后它又从设计师和构建的解决方案中消失了?
现在,我可以继续可靠地重现此方案。对UserControl进行一些更改,它会重新出现在设计器中.....然后进行构建,然后它又消失了!
有人能请您对此杂乱无章的事物有所启发吗?与Caliburn Micro一起在SL中运行(无论是在浏览器中还是在浏览器中,但都内置在浏览器中)。当然,对这个谜的任何见解都会受到赞赏,希望另一双眼睛能抓住我的愚蠢。干杯!
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
mc:Ignorable="d"
x:Class="My.Project.Controls.DatePicker">
<Grid Width="90">
<telerik:RadDateTimePicker
InputMode="DatePicker"
SelectedDate="{Binding SelectedDate, Mode=TwoWay}"/>
<telerik:RadMaskedDateTimeInput
IsClearButtonVisible="False"
FormatString="{}{0:M/d/yy}"
SelectionOnFocus="SelectAll"
Value="{Binding SelectedDate, Mode=TwoWay}"/>
</Grid>
</UserControl>
Run Code Online (Sandbox Code Playgroud)
然后,我将直接在像这样的视图上调用它(如名称空间所示,它将位于GlobalUserControlDump项目中),一旦将名称空间添加到视图中,它就会按预期在智能感知中正常显示;
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:cal="clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
x:Class="My.Project.Views.RandomView"
xmlns:Controls="clr-namespace:My.Project.Controls;assembly=My.Project.GlobalUserControlDump"
mc:Ignorable="d">
<Grid>
<Controls:DatePicker />
</Grid>
</UserControl>
Run Code Online (Sandbox Code Playgroud)
然后,通过所需的属性进行公开;
namespace My
{
public partial class DatePicker : UserControl
{
public static readonly DependencyProperty SelectedDateProperty =
DependencyProperty.Register("SelectedDate", typeof(DateTime), typeof(DatePicker), new PropertyMetadata(null));
public …Run Code Online (Sandbox Code Playgroud) 我想按降序对包含日期字符串的数组进行排序,我尝试了SO答案,但输出错误了.
请参阅我的代码如下:
NSArray *dateArray=[NSArray arrayWithObjects:@"01/12/2012",@"01/26/2011",@"02/09/2005",@"02/24/2006",@"03/19/2007",@"07/14/2011",@"08/17/2007",@"10/04/2007",@"10/31/2006",@"12/05/2012",@"12/06/2006",@"12/23/2008",nil];
NSDateFormatter *formatter=[[NSDateFormatter alloc]init];
[formatter setDateFormat:@"MM/DD/YYYY"];
NSMutableArray *tempArr=[[NSMutableArray alloc]init];
for (int i=0; i<[dateArray count]; i++) {
NSString *dt=[dateArray objectAtIndex:i];
NSDate *newDt=[formatter dateFromString:dt];
[tempArr addObject:newDt];
}
NSLog(@"tempArr is %@",tempArr);
Run Code Online (Sandbox Code Playgroud)
我得到如下控制台输出:
2013-08-27 15:29:50.418样本[3688:c07] tempArr是("2011-12-24 18:30:00 +0000","2010-12-18 18:30:00 +0000"," 2004-12-18 18:30:00 +0000","2005-12-24 18:30:00 +0000","2006-12-23 18:30:00 +0000","2010-12-18 18:30:00 +0000","2006-12-23 18:30:00 +0000","2006-12-23 18:30:00 +0000","2005-12-24 18:30:00 +0000","2011-12-24 18:30:00 +0000","2005-12-24 18:30:00 +0000","2007-12-22 18:30:00 +0000")
我不知道为什么"12"会在月份出现,而且日期格式也不像我指定的格式.
我有以下 XAML 片段:
<TextBox x:Name="FilterTB" TextChanged="FilterTB_TextChanged"/>
<Button x:Name="CancelFilterSelectionButton" FontWeight="Bold" Content="X"/>
Run Code Online (Sandbox Code Playgroud)
我想在用户按下按钮时删除文本框的内容。
当然,从代码隐藏中执行此操作是一项微不足道的任务,但我只想通过使用 XAML 来完成它,因此使用触发器。
我尝试在网上进行研究,但我要么找到不正确的解决方案,要么发现过于复杂的解决方案,所以我想听到一些干净紧凑的解决方案。
如何在 Windows 通用应用资源中定义 XAML 边距?我试图将其定义为
<Thickness x:Key="MyMargin" Left="10" Top="20" Right="10" Bottom="20" />
Run Code Online (Sandbox Code Playgroud)
由此无法编译,我得到
XamlCompiler 错误 WMC0100:无法构造 XAML Thickness 类型。为了在 XAML 中构造,类型不能是抽象、接口、嵌套、泛型或结构,并且必须具有公共默认构造函数
因此,在XAML中,您可以设置一个方便的小绑定基础属性FallbackValue,在我可能没有数据立即可用的情况下进行设计时经常使用,但也不需要实际设置设计时间数据.
我试图找出在Angular绑定中是否有相同的东西我可以用于相同的目的.基本上只是一种快速/简单的方法来在绑定失败时获得一些显示数据?
就像在XAML中一样,Text="{Binding Blah, FallbackValue=FAIL}"如果没有数据则会显示FAIL.Angular是否还有一个等效的班轮?到目前为止,我的搜索还没有找到解决方案,但也许我只是没有使用正确的命名法.谢谢
我遇到了一个我不明白的问题。我的Visual Studio给我以下2个错误:
属性“ VisualTree”只能设置一次。
属性“ VisualTree”已设置多次。
这是我的XAML:
<ItemsControl x:Name="SettingsListItemControl">
<TextBlock Text="Settings" FontSize="24" />
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel HorizontalAlignment="Left" Height="640" VerticalAlignment="Top" Width="360" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate x:Name="SettingItemTemplate" x:DataType="vm:SettingItemViewModel">
<TextBlock Text="{x:Bind Title}"/>
<ToggleSwitch IsOn="{x:Bind IsActive}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
Run Code Online (Sandbox Code Playgroud)
我不知道为什么我不能绑定IsActive,这给我一个错误。似乎他也有DataTemplate问题。我的问题似乎很基本,我是XAML和DataBinding的初学者:)
感谢帮助!
嗨,我有一个齿轮 svg,我正在尝试通过其路径实现旋转动画,但由于某种原因,它没有从中心旋转。正如您在下面的代码片段中看到的那样,我有一个path带 anid outer-1并且我已经应用了一个对其调用的动画rotate,但它没有按预期工作。
.svg {
height: 400px;
width: 400px;
}
#outer-1 {
-webkit-transform-origin: center center;
animation-name:rotate;
animation-duration: 2s;
animation-timing-function: linear;
animation-iteration-count: infinite;
}
@keyframes rotate {
from {
-webkit-transform:rotate(0deg) translateZ(0px);
}
to {
-webkit-transform:rotate(360deg) translateZ(0px);
}
}Run Code Online (Sandbox Code Playgroud)
<div class="svg">
<svg viewBox="0 0 816 845" fill="none">
<g id="Layer 2">
<g id="Layer 1">
<path id="outer-2" d="M458.855 639.621C458.856 630.178 462.475 621.074 469.008 614.076C475.541 607.078 484.522 602.687 494.205 601.756C488.616 573.484 476.953 546.671 459.975 523.064C452.496 529.175 442.934 532.355 …Run Code Online (Sandbox Code Playgroud)