在 WPF 中,我可以创建一个故事板作为页面/控件资源,然后多次将其用于该页面(或父控件)内的控件...
<Grid Background="{DynamicResource CorporateLogoBackgroundBrush}" views:MainWindowHelper.DragWindowOnMouseDown="True">
<Grid.Resources>
<Storyboard x:Key="FlashRedBackgroundStoryboard">
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Duration="0:0:1" RepeatBehavior="Forever">
<ObjectAnimationUsingKeyFrames.KeyFrames>
<DiscreteObjectKeyFrame KeyTime="0:0:0.5">
<DiscreteObjectKeyFrame.Value>
<SolidColorBrush Color="Red" />
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames.KeyFrames>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</Grid.Resources>
<Border Grid.Column="4" BorderThickness="0">
<Border.Style>
<Style TargetType="{x:Type Border}">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=IsNetworkConnectivityOk}" Value="false">
<DataTrigger.EnterActions>
<BeginStoryboard Name="FlashRedBackgroundStoryboard">
<StaticResource ResourceKey="FlashRedBackgroundStoryboard" />
</BeginStoryboard>
</DataTrigger.EnterActions>
<DataTrigger.ExitActions>
<StopStoryboard BeginStoryboardName="FlashRedBackgroundStoryboard"></StopStoryboard>
</DataTrigger.ExitActions>
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
<TextBlock Text="LAN/WLAN" />
</Border>
<Border Grid.Column="5" BorderThickness="0">
<Border.Style>
<Style TargetType="{x:Type Border}">
<Setter Property="Background" Value="{DynamicResource CorporateLogoBackgroundBrush}" />
<Style.Triggers>
<DataTrigger Binding="{Binding Path=SynchronisationClientService.IsActive}" Value="true">
<Setter Property="Background" Value="Green" /> …Run Code Online (Sandbox Code Playgroud) 有没有办法在 Xaml Image 控件上显示 SoftwareBitmap 而不将 SoftwareBitmap 保存到文件?我想要一种在编辑后快速显示 SoftwareBitmap 的方法。
我正在使用 VS2015 开发 UWP Win10 应用程序。我正在使用 ContenDialog 显示模态窗口/弹出窗口。我需要更改 ContentDialog 的背景叠加颜色。这个怎么做。即使在内部样式中也没有选项/属性。
我需要将覆盖白色暗淡颜色更改为其他颜色,例如黑色覆盖/暗淡颜色等......
看图片。
在我的页面右侧有一些文本框(第1页),在左侧有一些按钮,如文本框上的1,2,3(第2页),焦点页面2出现在框架中.现在我的问题是如何在uwp中第2页的按钮点击的第1页的文本框中设置值.
我在共享的PCL(适用于android和uwp应用)中具有模型类,其中包含datetime属性:
public class Meter {
public int meter_value {get; set; }
public DateTime meter_start { get; set; }
public DateTime meter_end { get; set; }
... other int and string properties
}
Run Code Online (Sandbox Code Playgroud)
在MainPage.cs中,我有
public Meter _meter;
public MainPage()
{
this.InitializeComponent();
_meter = new Meter();
}
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用以下代码将其绑定到xaml控件:
<TextBox
Text="{x:Bind _meter.meter_value, Mode=TwoWay}">
<CalendarDatePicker
Name="meter_start"
Date="{x:Bind _meter.meter_start, Mode=TwoWay}"
DateFormat="{}{day.integer}/{month.integer}/{year.full}" >
</CalendarDatePicker>
Run Code Online (Sandbox Code Playgroud)
此代码产生编译时错误: Invalid binding path '_meter.meter_start' : Cannot bind type 'System.DateTime' to 'System.Nullable(System.DateTimeOffset)' without a converter
当我将x:Bind更改为Binding时,将进行applicaton编译,但是我的模型中meter_start属性的值为0001/01/01。
有人可以帮我解决这个问题吗?
我在通用Windows平台中使用列表视图模板,希望我做的一切正确,但是当应用程序首次加载时,列表视图中的第一项具有黑色边框。
我在UI中所做的是
<Page
x:Class="ListViewExample.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:ListViewExample"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:data="using:ListViewExample.Model"
mc:Ignorable="d">
<Page.Resources>
<DataTemplate x:Key="BookListDataTemplate" x:DataType="data:Book">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
<Image Name="image" Source="{x:Bind CoverImage}" HorizontalAlignment="Center" Width="150" />
<StackPanel Margin="20,20,0,0" Width="100">
<TextBlock TextWrapping="Wrap" Text="{x:Bind Title}" HorizontalAlignment="Center" FontSize="16" Width="auto" />
<TextBlock TextWrapping="Wrap" Text="{x:Bind Author}" HorizontalAlignment="Center" FontSize="10" Width="auto" />
</StackPanel>
</StackPanel>
</DataTemplate>
<Style TargetType="ListViewItem" x:Key="stylez">
<Setter Property="FocusVisualPrimaryThickness" Value="0" />
<Setter Property="FocusVisualSecondaryThickness" Value="0" />
</Style>
</Page.Resources>
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<RelativePanel >
<Button Name="hambergerbutton" FontSize="36" RelativePanel.AlignLeftWithPanel="True"
FontFamily="Segoe MDL2 Assets" Content="" Click="hambergerbutton_Click" …Run Code Online (Sandbox Code Playgroud) 我注意到应用 程序卸载后删除了保存到 ApplicationData.Current.LocalFolder.CreateFileAsync文件夹中的文件.
是否可以保存在应用程序卸载后保留在用户事件探查器中的文件,因此当用户重新安装应用程序时,我可以从该文件中读取该用户的设置?
我遇到的问题是,如果我将文本框的宽度设置为 70 以下,它将无法完全显示。我已将 设为MinWidth0,但TextBox仍显示为下图中下方的文本框。上面的宽度我设置为70,它完全显示。我需要在模板中更改某些内容才能使其正常工作吗?有任何想法吗?
<TextBox
Width="30"
Height="50"
MinWidth="0" />
Run Code Online (Sandbox Code Playgroud)
我还尝试在 Visual Studio 的设计器中编辑模板TextBox。我单击“编辑模板”,但没有任何反应,但它与其他控件一起工作正常。
我的原始代码:我将第一个文本框的宽度设置为 50,其余设置为 70。
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
</Grid.ColumnDefinitions>
<Grid Grid.Column="0" Margin="10,0">
<controls:DropShadowPanel
BlurRadius="40"
ShadowOpacity="0.3"
Color="{StaticResource blueColor}">
<TextBox
Width="50"
x:Name="Code0"
Height="80"
MinWidth="0"
Background="White"
BorderBrush="{StaticResource blueColor}"
BorderThickness="1"
CornerRadius="10"
FontSize="55"
TextAlignment="Center" />
</controls:DropShadowPanel>
</Grid>
<Grid Grid.Column="1" Margin="10,0">
<controls:DropShadowPanel
BlurRadius="40"
ShadowOpacity="0.3"
Color="{StaticResource blueColor}">
<TextBox
Width="70"
x:Name="Code1"
Height="80"
MinWidth="0"
Background="White"
BorderBrush="{StaticResource …Run Code Online (Sandbox Code Playgroud) 如果我使用 PivotItem 而不是 WinUI 的 TabView 控件,RichEditBox 将扩展到整页。但是,当将它与 TabView 一起使用时,RichEditBox 只占用一行空间,如下所示:https ://prnt.sc/ravdw6
将 RichEditBox 的 height 属性设置为 800 之类的常量可以工作,但不喜欢在 UI 中使用常量。这是有问题的代码:
<muxc:TabView x:Name="Tabs"
AddTabButtonClick="Tabs_AddTabButtonClick"
Grid.Column="1"
Grid.RowSpan="2">
<muxc:TabView.TabItems>
<muxc:TabViewItem Header="Entry 1">
<muxc:TabViewItem.IconSource>
<muxc:SymbolIconSource Symbol="NewFolder" />
</muxc:TabViewItem.IconSource>
<muxc:TabViewItem.Content>
<StackPanel>
<RichEditBox x:Name="MainRichEdit"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"/>
</StackPanel>
</muxc:TabViewItem.Content>
</muxc:TabViewItem>
</muxc:TabView.TabItems>
</muxc:TabView>
Run Code Online (Sandbox Code Playgroud) 我想在我的应用程序中添加“退出”按钮。
如果我写这样的东西:
void LibraryUWP::MainPage::ExitEvent(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
Application::Exit;
}
Run Code Online (Sandbox Code Playgroud)
我有一个错误:
1>...\mainpage.xaml.cpp(32): 错误 C3867: 'Windows::UI::Xaml::Application::Exit': 非标准语法;使用“&”创建指向成员的指针
如果我跑
void LibraryUWP::MainPage::ExitEvent(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
Application::Exit();
}
Run Code Online (Sandbox Code Playgroud)
我有:
1>...\mainpage.xaml.cpp(32): 错误 C2352: 'Windows::UI::Xaml::Application::Exit': 非静态成员函数的非法调用
如果我运行这个:
void LibraryUWP::MainPage::ExitEvent(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
Application::Current::Exit();
}
Run Code Online (Sandbox Code Playgroud)
我有一个错误:
1>...\mainpage.xaml.cpp(32): error C2039: 'Exit': is not a member of 'Windows::UI::Xaml::Application::Current'
1>...\mainpage. xaml.cpp(32):错误 C3861:“退出”:未找到标识符
我明白,第一个和第二个变体不能工作。但是第三个呢?或者是其他东西?
MS Visual Studio 2015 更新 3。适用于 Windows 10.10240 平台
PS如果我在没有最后一个护腕的情况下运行第三个变体,我会遇到同样的错误,这告诉我,我们没有这样的方法。
uwp-xaml ×10
uwp ×8
xaml ×4
c# ×3
bitmap ×1
c#-4.0 ×1
c++ ×1
image ×1
windows-10 ×1
xamarin.uwp ×1