我有一个订单列表,当订单状态为Cancelled时,我想要闪烁文本.到目前为止,我的代码工作.但是,有时会抛出异常:
WinRT信息:无法解析TargetName lblOrderStatus
由于某种原因,可以找到lblOrderStatus.所以,我想使用"FindAncestor",但UWP中不存在FindAncestor.在uwp中是否有与FindAncestor等效的功能?
这是我的代码:
<ItemsControl x:Name="Orders" Grid.Row="1" Background="Transparent">
...
...
...
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid>
...
...
...
<Viewbox Grid.Column="3" StretchDirection="DownOnly" HorizontalAlignment="Right">
<TextBlock x:Name="lblOrderStatus" Text="{Binding Path=OrderItemStatus, Mode=OneWay}" FontSize="18">
<TextBlock.Resources>
<Storyboard x:Name="sbBlinking">
<DoubleAnimation Storyboard.TargetProperty="(FrameworkElement.Opacity)"
Storyboard.TargetName="lblOrderStatus"
From="1" To="0" AutoReverse="True" Duration="0:0:0.5" RepeatBehavior="Forever" />
</Storyboard>
</TextBlock.Resources>
<interactive:Interaction.Behaviors>
<core:DataTriggerBehavior Binding="{Binding OrderItemStatus, Converter={StaticResource EnumToStringConverter}}" ComparisonCondition="Equal" Value="Cancelled">
<media:ControlStoryboardAction Storyboard="{StaticResource sbBlinking}" />
</core:DataTriggerBehavior>
</interactive:Interaction.Behaviors>
</TextBlock>
</Viewbox>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
Run Code Online (Sandbox Code Playgroud) 这个问题让我发疯了.我正在使用Microsoft SQLExpress 2016来编写存储过程.其中一个要求是进行舍入.但是时不时地四舍五入是错误的.我发现T-SQL舍入与C#不完全相同,但为什么呢?
比较下面的两个舍入:
In T-SQL: ROUND(0.045, 2) --> this will produce 0.05
In C#: Math.Round(0.045, 2) --> this will produce 0.04
Run Code Online (Sandbox Code Playgroud)
为什么C#产生0.04?不应该是0.05吗?
我该怎么办才能使C#舍入= T-SQL舍入?谁能帮我?
谢谢,山姆
出于好奇,我在C#中尝试了这个:
Math.Round(0.055, 2)
Run Code Online (Sandbox Code Playgroud)
猜猜看,C#将它四舍五入?它四舍五入到0.06!现在,我完全糊涂了!
Math.Round(0.045, 2) //this becomes 0.04
Math.Round(0.055, 2) //this becomes 0.06
Run Code Online (Sandbox Code Playgroud)
有谁能解释一下?
谢谢
我正在为自助服务终端模式编写Android应用程序.我正在使用本教程创建自助服务终端模式:http://www.andreas-schrade.de/2015/02/16/android-tutorial-how-to-create-a-kiosk-mode-in-android/
但是,在本教程中,用户仍然可以单击主页,然后在2秒后返回应用程序.
所以,我做了一些修改,通过将我的应用程序作为一个家来禁用主页按钮.我把它放在我的清单中就做到了:
<activity android:name=".MainActivity"
android:launchMode="singleInstance">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME"/>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
一切都运作良好.但是当用户尝试退出(即用户以管理员身份登录)时,我的应用程序又回来了.我怀疑是因为我把它设为HOME.
我的问题是,如何允许我的应用程序退出.当我的应用程序退出时,是否可以返回实际的家?如果没有,是否有更好的方法来解决这个家庭问题(即禁用主页按钮,而不是实际设置为家)?
我有一个名为TestGUILib 的模块,并且使用简单的 FrameLayout指定了testview.xml 。
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Testing View!" />
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
我尝试在我的主应用程序Activity_main中使用此布局。这是我的代码:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.sam.testapp1.MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<include layout="@layout/testview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
/>
</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)
一切正常。编译正常,运行正常。但预览不起作用。它显示空白屏幕(即,当我单击“设计”时,它变成空白)并出现渲染错误:
在当前配置中找不到布局资源匹配值 0x7F04002F(解析名称:testview)。
另外, testview下有一行(即 include layout="@layout/ testview ")。当我滚动鼠标时,它说
“testview”一词中的拼写错误
拼写检查器检查有助于查找代码、注释和文字中的拼写错误和拼写错误,并一键修复它们。
任何想法?谢谢
我需要有关Realm中LinkingObjects的帮助。请查看以下简单代码:
public class Product extends RealmObject
{
@PrimaryKey
private int prodId;
@Required
private String name;
private RealmList<ProductItem> productItems;
@LinkingObjects("productParent")
private final RealmResults<ProductItem> linkProductItems = null;
...
...
...
}
public class ProductItem extends RealmObject
{
@PrimaryKey
private String primaryKey;
private int prodId;
private int prodItemId;
private String itemCode;
private double price;
private Product productParent;
...
...
...
public Product getProductParent()
{
return productParent;
}
}
Run Code Online (Sandbox Code Playgroud)
然后,我通过执行以下操作添加了示例数据:
realm.beginTransaction();
Product prod = new Product();
prod.setProdId(1);
prod.setName("Test");
prod = realm.copyToRealm(prod);
ProductItem prodItem = …Run Code Online (Sandbox Code Playgroud) 在Entity Framework Core 1.0 RC2(以前的Entity Framework 7 RC2)中,默认情况下,所有整数主键都是自动增量字段.我尝试了一切来删除它.从使用数据注释到流畅的API,没有任何作用.
使用数据注释:
[Key, Column(Order = 1, TypeName = "INT"), DatabaseGenerated(DatabaseGeneratedOption.None)]
Run Code Online (Sandbox Code Playgroud)
使用流畅的API:
modelBuilder.Entity<tblProduct>().HasKey(t => t.ProdId).HasAnnotation("DatabaseGenerated", DatabaseGeneratedOption.None);
//OR use the following
modelBuilder.Entity<tblProduct>().HasKey(t => t.ProdId).HasAnnotation("DatabaseGenerated", 0);
//OR use the following
modelBuilder.Entity<tblProduct>().HasKey(t => t.ProdId).HasAnnotation("Sqlite:Autoincrement", false);
Run Code Online (Sandbox Code Playgroud)
没有任何工作:(
你能帮我么?
正如请求的那样,这是运行add-migration LocalDB_v1后得到的表脚本
migrationBuilder.CreateTable(
name: "tblProduct",
columns: table => new
{
ProdId = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(nullable: true),
Description = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_tblProduct", x => x.ProdId);
});
... …Run Code Online (Sandbox Code Playgroud) 这可能听起来很简单,但我找不到办法.
我只想在TextBlock中使用闪烁的文本.有办法轻松完成吗?
我能想到的唯一方法是使用计时器并手动更改TextBlock前景.当然有一种简单的方法可以做到这一点.我只是无法搞清楚.
谢谢!
我有一个非常奇怪的问题。如果我设置了绑定并将绑定更改为另一个属性,它将不起作用。
看这个简单的例子
lblTotal.SetBinding(TextBlock.TextProperty, new Binding() { Path = new PropertyPath("Subtotal"), Source = Order, Mode = BindingMode.OneWay });
lblTotal.SetBinding(TextBlock.TextProperty, new Binding() { Path = new PropertyPath("FinalTotal"), Source = Order, Mode = BindingMode.OneWay });
Run Code Online (Sandbox Code Playgroud)
当FinalTotal改变时, lblTotal 文本不会改变。
现在,注释掉第一行。
//lblTotal.SetBinding(TextBlock.TextProperty, new Binding() { Path = new PropertyPath("Subtotal"), Source = Order, Mode = BindingMode.OneWay });
lblTotal.SetBinding(TextBlock.TextProperty, new Binding() { Path = new PropertyPath("FinalTotal"), Source = Order, Mode = BindingMode.OneWay });
Run Code Online (Sandbox Code Playgroud)
现在它起作用了!!!!更改FinalTotal将更改 lblTotal 文本!知道为什么吗?
此外,BindingOperations.ClearBinding()在 UWP 中不可用。所以我试图用空绑定替换它,但它仍然不起作用。 …
我有一个非常快的问题.如何获取特定字段(字符串类型)不为空且为空的所有记录.
目前,我这样做:
String nullStr = null; //temporary null string to pass it to realm.
RealmResults<Feedback> feedbacks = realm.where(Feedback.class)
.notEqualTo("Comment", nullStr)
.notEqualTo("Comment", "")
.findAll();
Run Code Online (Sandbox Code Playgroud)
这是获取非空和空的记录的唯一方法吗?如果Comment只包含空格怎么样?有没有办法获取记录,其中字段不为空并且不包含空格?
谢谢
MinWindowWidth=2160 的 AdaptiveTrigger 似乎不起作用。我需要它来处理 Microsoft Surface Pro 3 屏幕分辨率 (2160x1440)。
看看下面这个简单的代码:
<Page
x:Class="TestUWP.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:TestUWP"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="2160" d:DesignHeight="1440">
<Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<VisualState>
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="2160" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="brdMain.Background" Value="#bbbbbb"></Setter>
</VisualState.Setters>
</VisualState>
<VisualState>
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="0" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="brdMain.Background" Value="#303030"></Setter>
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Border x:Name="brdMain">
<TextBlock Text="Testing"></TextBlock>
</Border>
</Grid>
</Page>
Run Code Online (Sandbox Code Playgroud)
您会看到,背景颜色始终为黑色 (#303030)。是否有 VisualState 可以处理的最大宽度?任何的想法?
谢谢
我有一个回收器视图,我需要使用颜色选择器之一(具体取决于数据绑定中的值)来更改 TextView 颜色。
我有两个选择器:
颜色/selector_item_text.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/white" android:state_checked="true" />
<item android:color="@color/white" android:state_pressed="true" />
<item android:color="@color/white" android:state_activated="true" />
<item android:color="@color/black" />
</selector>
Run Code Online (Sandbox Code Playgroud)
颜色/selector_item_textwithspecial.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/pink" android:state_checked="true" />
<item android:color="@color/pink" android:state_pressed="true" />
<item android:color="@color/pink" android:state_activated="true" />
<item android:color="@color/orange" />
</selector>
Run Code Online (Sandbox Code Playgroud)
我将它绑定到我的 TextView 上,如下所示:
<TextView android:text="@{data.displayPrice}"
android:textColor="@{data.isSpecial ? @color/selector_item_textwithspecial : @color/selector_item_text}"
style="@style/ProductPrice"/>
Run Code Online (Sandbox Code Playgroud)
问题是 TextView 颜色始终是橙色(如果有特殊)或黑色。选择永远不会改变颜色。但是,如果我删除数据绑定,它就会按预期工作。
例如,下面的代码将使 TextView 变成粉色(选中时)和橙色(未选中时)
<TextView android:text="@{data.displayPrice}"
android:textColor="@color/selector_item_textwithspecial"
style="@style/ProductPrice"/>
Run Code Online (Sandbox Code Playgroud)
知道如何解决这个问题吗?
谢谢...
android textcolor android-selector android-databinding android-text-color