我在互联网上寻找解决方案,但无法在我的样本中找到它.我需要在从代码隐藏生成的Context菜单项之间添加一个分隔符.我尝试使用如下代码行添加它但没有成功.
this.Commands.Add(new ToolStripSeparator());
Run Code Online (Sandbox Code Playgroud)
我想知道是否有人可以提供帮助.先感谢您.
上下文菜单XAML:
<Style x:Key="DataGridCellStyle" TargetType="{x:Type DataGridCell}">
<Setter Property="ContextMenu">
<Setter.Value>
<ContextMenu ItemsSource="{Binding Commands}">
<ContextMenu.ItemContainerStyle>
<Style TargetType="{x:Type MenuItem}">
<Setter Property="Command" Value="{Binding}" />
<Setter Property="Header" Value="{Binding Path=Text}" />
<Setter Property="CommandParameter" Value="{Binding Path=Parameter}" />
</Style>
</ContextMenu.ItemContainerStyle>
</ContextMenu>
</Setter.Value>
</Setter>
Run Code Online (Sandbox Code Playgroud)
在方法中添加的C#:
this.Commands = new ObservableCollection<ICommand>();
this.Commands.Add(MainWindow.AddRole1);
this.Commands.Add(MainWindow.AddRole2);
this.Commands.Add(MainWindow.AddRole3);
this.Commands.Add(MainWindow.AddRole4);
//this.Add(new ToolStripSeparator());
this.Commands.Add(MainWindow.AddRole5);
this.Commands.Add(MainWindow.AddRole6);
this.Commands.Add(MainWindow.AddRole7);
Run Code Online (Sandbox Code Playgroud) 我想知道是否有可能延迟数据触发器将布局更改为0.5秒.有什么简单的方法吗?我需要设置对象的可见性,但等待0.5秒.任何adeas都非常感谢.
<DataTemplate x:Key="ListBoxItemDataTemplate">
<Grid x:Name="DataItem">
<Image x:Name="IconImage" Source="{Binding XPath=@icon}" Height="16" Margin="16,0,0,0" Stretch="None" VerticalAlignment="Center" HorizontalAlignment="Left" />
<TextBlock x:Name="ListboxIemtextBlock" Text="{Binding XPath=@name}" />
<Image x:Name="ArrowImage" Height="10" Source="Resources/Images/arrow_collapsed_grey.png" Visibility="{Binding XPath=@state}"/>
</Grid>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}, Mode=FindAncestor}}" Value="True">
<Setter TargetName="ListboxIemtextBlock" Property="Foreground" Value="White"/>
<Setter TargetName="IconImage" Property="Source" Value="{Binding XPath=@iconSelected}"/>
<Setter TargetName="IconImage" Property="Height" Value="16"/>
<Setter TargetName="ArrowImage" Property="Source" Value="Resources/Images/arrow_collapsed_white.png"/>
</DataTrigger>
<DataTrigger Binding="{Binding IsMouseOver, RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}, Mode=FindAncestor}}" Value="True">
<Setter TargetName="ListboxIemtextBlock" Property="Foreground" Value="#FF6dacbe"/>
</DataTrigger>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type ListBox}}, Path=SelectedItem.Attributes[retract].Value}" Value="True">
<Setter TargetName="ListboxIemtextBlock" Property="Visibility" Value="Hidden" />
<DataTrigger.EnterActions> …Run Code Online (Sandbox Code Playgroud) 我想知道是否有人知道复选标记符号的标记.我需要在texblock中使用它.我在网上寻找任何线索,并没有发现任何可以与XAML一起使用的东西.先感谢您.
我遇到了问题.我在窗口xaml中添加了一个框架来加载页面.我可以直接将页面加载到框架的Source标签的框架中.有用.我需要使用C#中的代码来引用列表框菜单中的链接,在选择列表框项目时弹出适当的链接.我的问题是我不能在C#代码中引用框架,它只是无法看到.我用x:Name ="ContentFrame"定义了框架.当我在C#中引用时,Intellisense告诉"当前上下文中不存在名称"ContentFrame".我做错了什么?我迷失在这里.任何想法都受到高度赞赏.这是代码:
<Frame x:Name="ContentFrame" JournalOwnership="OwnsJournal" NavigationUIVisibility="Hidden" Grid.Column="2" </Frame>
private void SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
ListBoxItem lbi = ((sender as ListBox).SelectedItem as ListBoxItem);
string itemName = lbi.Content.ToString();
if ( Nav_ListBox.SelectedItem.Equals("Page1" ) )
{
ContentFrame.Source = new Uri("Pages/Page1.xaml", UriKind.Relative);
Canvas_Frame.NavigationUIVisibility = NavigationUIVisibility.Hidden;
}
}
Run Code Online (Sandbox Code Playgroud)
`
如何将 setter 分配给条件值(例如 more than )0?如果值不是,我需要隐藏一个对象0。最好的方法是什么?任何想法都受到高度赞赏。
XAML 示例DataTrigger:
<DataTrigger Binding="{Binding Role.Count}" Value="0">
<Setter TargetName="Counts" Property="Visibility" Value="Hidden" />
</DataTrigger>
Run Code Online (Sandbox Code Playgroud) 我想知道是否有任何简单的技术来运行故事板,如果文本块文本字符串被更改.先感谢您!
如果动态生成的值等于零,我想让texblock不可见.我认为可以使用DataTrigger单独在XAML中完成.我想知道是否有人可以帮助找到适当的解决方案.先感谢您.
我需要根据绑定中的textblock文本字符串值更改边框背景颜色.我计划使用触发器,但Silverlight不支持它.我正在寻找有关如何在Silverlight中实现的任何建议.先感谢您!
XAML:
<data:DataGridTemplateColumn Header="Y Position" Width="100">
<data:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Border Background="Red" Width="10" Height="18" VerticalAlignment="Center" Margin="0,0,10,0" />
<TextBlock Text="{Binding Y}" VerticalAlignment="Center" />
</StackPanel>
</DataTemplate>
</data:DataGridTemplateColumn.CellTemplate>
</data:DataGridTemplateColumn>
Run Code Online (Sandbox Code Playgroud)
ViewModel代码:
public class MainPage_ViewModel : INotifyPropertyChanged
{
public
public MainPage_ViewModel()
{
coordinates.Add(new Coordinate_DataViewModel(new Coordinate_Model() { X = 1, Y = 2 }));
coordinates.Add(new Coordinate_DataViewModel(new Coordinate_Model() { X = 2, Y = 4 }));
coordinates.Add(new Coordinate_DataViewModel(new Coordinate_Model() { X = 3, Y = 6 }));
coordinates.Add(new Coordinate_DataViewModel(new Coordinate_Model() { X = 4, Y = 8 …Run Code Online (Sandbox Code Playgroud) wpf ×6
binding ×4
wpf-controls ×4
silverlight ×2
data-binding ×1
datagrid ×1
datatemplate ×1
frame ×1
navigation ×1
wpfdatagrid ×1