Tag: xaml

填充xaml矩形倍数solidcolorbrush

这种类型的xaml填充矩形是可能的吗? 我不想使用渐变来填充矩形,因为在每个部分的图像中使用不同的纯色刷。 谢谢

点击Generic.xaml中的按钮?

我正在Silverlight中编写自定义控件,我遇到问题让我的Button单击Generic.xaml文件。 这不起作用: < “ScrollLeft”在我的C#文件中。 但是,这也不起作用: var b = this.GetTemplateChild(“ScrollLeft”); Debug.Assert(b != null); 因为不管我做什么,b总是回来无效。 我觉得应该有一种简单的方法将click方法分配给这个按钮,所以我做错了什么? 编辑:这是我的C#文件中的方法: public void scrollLeft(object sender, RoutedEventArgs e) { //var scroller = Application.Current.Resources[“TabScroller”] as ScrollViewer; //scroller.LineLeft(); }

在特定位置的UI元素上方显示弹出窗口

我有gridView,它的项目非常简单,我在每个gridViewItem上都有按钮。 在此按钮上单击我想显示一个与gridViewItem具有相同内容的弹出按钮,但也显示更多数据。 这很容易,但我想将flyout定位在gridViewItem上方,使其显示的项目与gridViewItem项目完全相同。 此技术用于Windows 10的Store应用程序。当看到用户对应用程序的评论时。 点击更多会显示该弹出窗口。

将ControlTemplate XAML转换为C#

我一直难以尝试将以下代码转换为纯c#。 这个XAML代码来自Cavanaghs博客,关于如何在任何东西上制作圆角。 代码可以工作但我需要将它转换为c#,因为在某些情况下我需要它是动态的。 如果你能提供帮助那就太好了。 到目前为止,我有以下但我得到错误。 FrameworkElementFactory border = new FrameworkElementFactory(typeof(Border)); border.SetValue(Border.BackgroundProperty, Brushes.White); border.SetValue(Border.CornerRadiusProperty, new CornerRadius(8, 8, 8, 8)); border.SetValue(Border.NameProperty, “roundedMask”); 据我所知,我不能将VisualBrush作为FrameworkElementFactory(崩溃),但如果我将它声明为常规元素VisualBrush,我不能将其作为VisualE传递边界,因为它是一个FrameworkElementFactory。 只是我迷路了,任何帮助将不胜感激。 谢谢你的帮助

数据在不同窗口中的两个TextBox之间绑定

我创建了一个程序,在检查或取消检查复选框时更改TextBox中的名称。 我想在另一个窗口中复制此文本框。 我认为在xaml中使用Data Mining是可能的,但名称只出现在一个窗口中。 第二个窗口窗口不接收数据。 我告诉你两个窗口的代码。 你能帮助我吗? Thankss 窗口1.cs — namespace WpfApplication1 { public partial class Window1 : Window { Texto prueba = new Texto(“Carlos”); public static string s; public Window1() { InitializeComponent( ); // Fill initial person fields this.textBox1.Text = prueba.Name; } private void checkBox1_Checked(object sender, RoutedEventArgs e) { prueba.Name=”Carlos”; textBox1.DataContext = prueba; textBox1.Text […]

WPF SubControl(如TextBlock)不使用TemplateSelector从窗口inheritanceStyle

我需要帮助,因为我不明白为什么来自datatemplate的控件不会inheritance窗口资源中定义的样式。 可能有解决方法吗? 如果有人能给我一个解决方案,我会非常感激,因为我花了很多时间找到一些东西。 特此我的例子。 例如,horrizontal模板中的Texblock不对齐: Udapte:我添加了背景颜色。 样式应用于标签,但不应用于由datatemplate定义的totextblock和textbox。 **** using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Reflection; namespace WpfApplication3 { public class TemplateSelector : DataTemplateSelector { public DataTemplate DataTemplateH { get; set; } public DataTemplate DataTemplateV { get; set; } public override DataTemplate SelectTemplate(object item, DependencyObject […]

WPF标签顺序工作错误

我在WPF中有一个观点,我一直在努力使标签顺序正确。 我有三个文本框(让我们称之为Text1,Text2和Text3)和两个自定义控件,每个控件都有几个其他文本框和各种控件(让我们称之为Custom1和Custom2)。 布局使得选项卡流应该是Text1,Text2,Custom1,Custom2,Text3。 我在每个控件上设置TabIndex属性以匹配此排序,并validation所有这些属性都设置为IsTabStop。 问题是,实际的选项卡流是Text1,Text2,Text3,然后是Custom1,Custom2,我无法找出原因。 当它进入自定义控件时,它会按照我的预期正确地跨越它们中的每个控件。 我只是无法弄清楚为什么它进入第一个自定义控件之前进入第三个文本框。 我已经尝试了我能想到的一切,包括确保所有的xaml元素按Tab键排列,但似乎没有任何帮助。 在将注意力集中到任何自定义控件之前,我怀疑它正在覆盖所有基本控件,但我没有想法。 任何帮助都会很棒。 编辑:这是我的xaml:

将StackPanel.Visibility绑定到其子项的Visibility属性

我是DataBinding的新手,只是阅读它。 我想做的是以下内容: 我有一个包含许多子控件的StackPanel: 1 2 3 可以通过代码更改文本框的可见性属性。 现在,如果所有TextBox都设置为Visibility = Collapsed,我还希望StackPanel.Visibility设置为Collapsed,但是如果显示一个或多个TextBox(Visibility = Visible),StackPanel.Visibility也应该设置为Visible。 这可以通过简单的DataBinding实现,还是必须在C#代码中实现此function?

如何在Windows Phone 8.1中缓存页面

以前在Windows Phone 8.0应用程序中,我们可以通过这种方式更深入地浏览同一页面: NavigationService.Navigate(new Uri(“/SamePage.xaml”, UriKind.Relative)); 页面已自动缓存,因此在导航回来后,用户离开时列表上的位置相同。 但在Windows Phone Store Apps我们通过这种方式更深入地浏览同一页面: Frame.Navigate(typeof(SamePage), id); 但在导航回来之后它会再次加载数据,所以如果用户位于长列表的中间位置,那么现在他位于顶部: private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { // TODO: Create an appropriate data model for your problem domain to replace the sample data. var group = await SampleDataSource.GetGroupAsync((string)e.NavigationParameter); this.DefaultViewModel[“Group”] = group; } 如何像以前那样缓存页面,这样用户将在他离开的列表中的相同位置? (我也包括Windows应用程序,因为他们从较长时间开始熟悉它)。

LayoutTransform中的ScaleTransform不起作用,但与RenderTransform一起使用

我正在尝试在我的应用程序中做两件事。 1.缩放图像 可以使用RenderTransform 。 但需要在LayoutTransform实现以启用Scrollviewer 。 XAML 工作。 不工作 2.旋转图像 适用于ScaleTransform和RenderTransform但需要使用ScaleTransform来获取ScrollViewer 问题出在LayoutTransform和LayoutTransform 使用ScrollViewer无法同时实现RotateTransform和RotateTransform 我尝试过Canvas XAML 旋转的不同行为但能够实现两种function,但ScrollViewer不能滚动。 旋转canvas的行为 – 尝试用ViewBox做同样的事情 旋转使用ScrollViewer缩放不起作用。 完整代码如下 任何人都可以帮我提出建议。 为’GazTheDestroyer’建议的解决方案 XAML