I have a ribbon in my application with a contextual tab. I have managed to get the tab to show and hide itself correctly based on what is selected in my application. My question is, how would I get it to be automatically selected (i.e. brought to front) when it is shown?
I figured it out. Just needed to do a style trigger based on the visibility:
<r:RibbonTab Header="Options"
ContextualTabGroupHeader="Options"
Visibility="{Binding CurrentFiles.SelectedItem, Converter={StaticResource DSToVisConverter}}" >
<r:RibbonTab.Style>
<Style TargetType="r:RibbonTab">
<Style.Triggers>
<Trigger Property="Visibility" Value="Visible">
<Setter Property="IsSelected" Value="True" />
</Trigger>
</Style.Triggers>
</Style>
</r:RibbonTab.Style>
Related
I have a grid control,I don't need to show any default color(cell and row) when i clicked on the grid,I tried with some code to disable the default selected row color of grid but when i applied this code its worked as my expected bu the problem is that the border of grid is gone also
<dxg:GridControl.View>
<dxg:TableView ShowGroupPanel="False" Name="View1" >
<dxg:TableView.RowStyle>
<Style>
<Style.Triggers>
<Trigger Property="dxg:GridViewBase.IsFocusedRow" Value="True">
<Setter Property="dxg:RowControl.Background" Value="Transparent" />
</Trigger>
</Style.Triggers>
</Style>
</dxg:TableView.RowStyle>
<dxg:TableView.CellStyle>
<Style>
<Style.Triggers>
<Trigger Property="dxg:GridViewBase.IsFocusedCell" Value="True">
<Setter Property="dxg:RowControl.Background" Value="Transparent" />
</Trigger>
</Style.Triggers>
</Style>
</dxg:TableView.CellStyle>
</dxg:TableView>
</dxg:GridControl.View>
Here we can see that the second row border is missing in the grid
Please help me to sort out this issue...
Try to look over this article
Look carefully how to use FocusedRowStyle
Other words - I think using the FocusedRowStyle instead of RowStyle may solve this problem.
I am trying to set the tab color of the header when the tab is selected. I work with Mah:
<Style x:Key="MenuLevel2" BasedOn="{StaticResource MetroTabItem}" TargetType="{x:Type TabItem}">
<Setter Property="mah:ControlsHelper.HeaderFontSize" Value="20" />
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Foreground" Value="SteelBlue"/>
</Trigger>
<Trigger Property="IsSelected" Value="True">
<!-- Sould do the work -->
<Setter Property="Foreground" Value="SteelBlue"/>
</Trigger>
</Style.Triggers>
</Style>
The text of the header is unfortunately still the one from the theme color. Any clue?
Your problem lies in the Controls.TabControl.xaml of MahApps.Metro. Most of the design lies in a template. As you can see in line 227 and 274, the Foreground is not bound to any property like done with other properties like Underline or HeaderFontSize.
This means you can't style these properties explicit without creating a whole new template. Since dynamic resources are used as color a solution is to override the used resources. Here is a workaround to change the colors for a tab item like required:
<TabItem Header="TabItem1">
<TabItem.Resources>
<SolidColorBrush x:Key="AccentColorBrush" Color="SteelBlue"/>
<SolidColorBrush x:Key="HighlightBrush" Color="SteelBlue"/>
</TabItem.Resources>
</TabItem>
I have a TextBox inside my ListView. When I click on the textview, the SelectionChanged event of ListView is not fired.
Is there a way to fire that, so that the ListView item is selected?
Despite the fact that you have not asked a good question, I think I understand your problem. I'm assuming that when you said textview, you actually meant Textbox and that your problem is that your ListViewItem is not changed to the item that contains the TextBox that you clicked on. If this is so, then adding this Style should do the trick:
<Style x:Key="ListViewItemSelectionStyle" TargetType="{x:Type ListViewItem}">
<Style.Triggers>
<Trigger Property="IsKeyboardFocusWithin" Value="True">
<Setter Property="IsSelected" Value="True" />
</Trigger>
<Trigger Property="IsKeyboardFocusWithin" Value="False">
<Setter Property="IsSelected" Value="True" />
</Trigger>
</Style.Triggers>
</Style>
While it looks strange, the second part is to ensure that the item remains selected after it loses KeyboardFocus.
You haven't provided any code, but at a guess, you haven't handled the event:
<ListView SelectionChanged="MyEventHandler" ...
</ListView>
I have a style on my datagrid to disable a DataGridRow based on a property binding. This makes the row unselectable, which is what I want. However, I am still able to select the disabled rows using at least 2 other ways. The first is if I use a dragging motion between two enabled rows that surround the disabled row. The second is if I click on the "select all" button on the top left of the datagrid. Is there a way to make specific rows completely unselectable?
This is what I currently have:
<DataGrid.RowStyle>
<Style TargetType="{x:Type DataGridRow}">
<Style.Triggers>
<DataTrigger Binding="{Binding DisableMe}" Value="True">
<Setter Property="IsEnabled" Value="False" />
</DataTrigger>
</Style.Triggers>
</Style>
</DataGrid.RowStyle>
What about using the SelectionChanged event to undo the selection? I really don't think there is a straightforward way to it, anyway.
You could also change the row style so it appears unselected even if it IS selected, and filter it out the selection through code...
I just stumbled upon this thread with the same problem, and I want to point out that you can simply set enabled to false.
I don't think of any proper solution to this question. But as a workaround you can bind 'IsHitTestVisible' property of DataGrid to 'IsEnabled'.
<DataGrid.RowStyle>
<Style TargetType="{x:Type DataGridRow}">
<Setter Property="IsEnabled" Value="True" />
<Setter Property="IsHitTestVisible" Value="{Binding RelativeSource={RelativeSource Self},Path=IsEnabled}"/>
<Style.Triggers>
<DataTrigger Binding="{Binding DisableMe}" Value="True">
<Setter Property="IsEnabled" Value="False" />
</DataTrigger>
</Style.Triggers>
</Style>
</DataGrid.RowStyle>
I am using Expander in WPF to display my data. The default style for the Expander control contains a toggle button which shows/hides my content when I click on it.
How can I modify the style so that it expands when I hovers the mouse over the header and collapse when I move away?
Barebone setup should be this:
<Style TargetType="{x:Type Expander}">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="IsExpanded" Value="True" />
</Trigger>
</Style.Triggers>
</Style>
(Applies to the whole expander, not just the header. That would probably require messing with the template.)
It is possible to use databinding between isExpanded property an ismouseover:
IsExpanded="{Binding IsMouseOver, Mode=OneWay, RelativeSource={RelativeSource Self}}"