Articles of xaml

如何在XAML中使用string作为this.Frame.Navigate(typeof()?

在Xaml文件中我有 <ComboBox Grid.Row="2" Grid.Column="2" Margin="50,50,50,50" FontSize="50" SelectionChanged="NavigateKing"> <ComboBoxItem></ComboBoxItem> <ComboBoxItem Content="Prince Wijaya"></ComboBoxItem> <ComboBoxItem Content="Pandukabhaya"></ComboBoxItem> <ComboBoxItem Content="Dewanampiya Tissa"></ComboBoxItem> </ComboBox> 并在Xaml.Cs文件中 private void NavigateKing(object sender, SelectionChangedEventArgs e) { ComboBoxItem cbi = (ComboBoxItem)((sender as ComboBox).SelectedItem); string navigatingURI = cbi.Content.ToString(); this.Frame.Navigate(typeof(/*IntendedXaml filename should be here*/); } 而不是编写一个完整的if-else或switch-case的情况,我可以通过NavigationURI导航?

从WPFcombobox中获取选定项目,该combobox由来自访问数据库的数据填充

我有一个combobox使用下面的代码从访问数据库的数据填充 public void BindComboBox(ComboBox ComboBoxOrg) { con.Open(); orgload = new OleDbCommand("SELECT organization_id, short_name FROM organization", con); OleDbDataAdapter da = new OleDbDataAdapter(); da.SelectCommand = orgload; DataSet ds = new DataSet(); da.Fill(ds); ComboBoxOrg.ItemsSource = ds.Tables[0].DefaultView; ComboBoxOrg.DisplayMemberPath = ds.Tables[0].Columns["short_name"].ToString(); ComboBoxOrg.SelectedValuePath = ds.Tables[0].Columns["organization_id"].ToString(); con.Close(); } XAML UI代码是 <ComboBox x:Name="ComboBoxOrg" Width="308" Height="40" HorizontalAlignment="Left" VerticalAlignment="Top" FontSize="18" Margin="0,0,0,100" Foreground="#FF666666" ItemsSource="{Binding}"/> 我想获得select的项目,然后用它来查询一个表(用户),其中的id是存在的例如。 OleDbConnection […]

获取button的前景色

尝试了许多组合,如: SolidColorBrush b = (SolidColorBrush)myButton.Foreground; b.Color.ToString(); 它返回:Windows.Ui.Xaml.Media.SolidColorBrush 但我需要知道颜色,例如:白色。

名称“Key”在当前上下文中不存在

我是Windows应用程序编程的新手。 我想在用户按下返回键之后捕捉TextBox的input。 我不断收到错误“The name'Key'在当前上下文中不存在”。 我添加了“使用System.Windows.Input;” 但是我仍然得到相同的错误。 我错过了什么? using App1.Common; using System; using System.Windows.Input; using System.Collections.Generic; using System.IO; using System.Linq; using System.Runtime.InteropServices.WindowsRuntime; using Windows.Foundation; using Windows.Foundation.Collections; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls.Primitives; using Windows.UI.Xaml.Data; using Windows.UI.Xaml.Input; using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Navigation; // The Basic Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234237 namespace App1 { /// <summary> /// […]

X,Yanimation故事板上的button点击Windows8的应用程序

我花了整整一天的时间来研究XAML故事板的例子,但是WinRT / Windows8应用程序不能像WPF那样工作(至less我认为),而且我都很困惑。 我所需要的是一个button,点击时向左移动100px,向上移动100px。 我正在最难的时候弄明白这一点,而且我知道,一旦我find了我想要工作的东西,我就可以从那里工作。 另外,如果任何人都可以教我如何使用“Storyboard.TargetProperty”那真是太棒了。 <Rectangle Name="Rectangle01" Height="100" Width="100" Fill="Red"> <Rectangle.Resources> <Storyboard x:Name="myboard"> <DoubleAnimation Storyboard.TargetName="Rectangle01" Storyboard.TargetProperty="Width" From="100" To="3600" Duration="0:0:6" /> </Storyboard> </Rectangle.Resources> </Rectangle> 这里有一个我尝试做的事情的例子,只是乱七八糟的故事板。 这直到我试图执行它没有抛出一个错误,但它仍然无法正常工作。

如何将修改的属性绑定到控件Windows通用应用程序(XAML / C#)

我正在一个Windows通用应用程序,我正在努力解决数据绑定。 我有一个列表视图有一个项目模板和数据模板,其中自定义类的属性被绑定。 <ListView> <ListView.ItemTemplate> <DataTemplate> <Textblock Text="{Binding Name}"/> </DataTemplate> </ListView.ItemTemplate> </ListView> 这工作正常显示我的自定义类的所有实例在ObservableCollection我绑定到列表视图。 我想知道是否有某种方式修改绑定之前绑定,而不改变类本身。 我试图绑定string属性名称的大写,所以如果名称是Test我想要绑定TEST 。 目前我这样做的方式是有一个名为NameLabel单独的属性,我这样填充 NameLabel = Name.ToUpper(); 然而,这似乎很混乱,我想知道是否有一个更好的方式做到这一点,而不创build一个单独的财产?

使用FindControl无法从UserControl获取UIElement

Im tray_ing从代码后面使用FindControl方法从UserControl获取UIElement,但我得到一个空对象。 我调用FindControl方法:Canvas canvas = FindControl(this,typeof(Canvas),“mPDFView”); ScrollViewer touchLayer = FindControl(this,typeof(ScrollViewer),“mtouchLayer”); 其中FindControl方法是: public static T FindControl<T>(UIElement parent, Type targetType, string ControlName) where T : FrameworkElement { if (parent == null) return null; if (parent.GetType() == targetType && ((T)parent).Name == ControlName) { return (T)parent; } T result = null; int count = VisualTreeHelper.GetChildrenCount(parent); for (int i = […]

在使用sketchFlow创build多个屏幕尺寸的UI原型时,有哪些最佳实践的build议?

我正在寻找一个Windows应用程序的用户界面的原型。 该应用程序将部署在具有不同(物理)屏幕尺寸和宽高比的多个显示设备上。 希望能够在一个显示器上生成优化的场景,并快速检查布局在不同的屏幕尺寸,方向上是否正常。 也就是说,我想为一组场景创build原型,并在不同的屏幕上“自动”生成相同的场景。 对MS Sketchflow有肤浅的认识。 在http://www.wpftutorial.net/LayoutProperties.html#best上看到了一些最佳实践。 我想知道民间人士是否可以build议在素描stream程中遵循的最佳做法。 再见

Windows Phone SDK – XAML – 上边距的自动保证金

我的my Windows Phone app有以下XAML : <StackPanel Orientation="Horizontal"> <Grid x:Name="LayoutRoot"> <Image Source="{Binding ImageUrl}" Height="80" HorizontalAlignment="Left" Margin="10,10,0,0" Stretch="Fill" VerticalAlignment="Top" Width="93" /> <TextBlock name="NameBlock" Text="{Binding Name}" FontSize="30" Margin="150,20,0,0" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Top" Width="300" /> <TextBlock name="DescriptionBlock" Text="{Binding Description}" FontSize="25" Margin="150,150,0,0" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Top" Width="300" /> </Grid> </StackPanel> 目前,我有第二个TextBlock( DescriptionBlock )的边缘设置为一个静态值。 现在,因为我将第一个TextBlock ( NameBlock )的工作包装设置为"Wrap" ,所以TextBlock的高度是可变的。 有谁知道如何使DescriptionBlock的顶部边缘等于NameBlock的自动高度? 这将确保第二个DescriptionBlock出现在NameBlock正下方,而不pipeNameBlock的文本的长度NameBlock 。 非常感谢! […]

ToogleSwitch没有主题颜色

我在WindowsPhone 7.1程序中插入了一个toogleswitch,我想这个控件采用主题颜色(如Windows Phone上的“Alarm”程序)。 其实,我的toggleSwitch是这样的: 我会这样(像我的主题): 这是我的XAML代码: <toolkit:ToggleSwitch Margin="193,371,0,0" Name="toggleSwitch1" VerticalAlignment="Top" Width="190" Height="114" /> 你有想法吗? 我已经厌倦了几个技巧,但没有改变:( 非常感谢, 最好的祝福, 编辑: 我已经尝试过,但没有改变 <toolkit:ToggleSwitch Margin="193,371,0,0" Name="toggleSwitch1" VerticalAlignment="Top" Width="190" Height="114" Header="{Binding Path=LocalisedResources.Show24HourText}"> <toolkit:ToggleSwitch.HeaderTemplate> <DataTemplate> <ContentControl Foreground="{StaticResource PhoneForegroundBrush}" Content="{Binding}" /> </DataTemplate> </toolkit:ToggleSwitch.HeaderTemplate> </toolkit:ToggleSwitch>