c# - WPF: Two TabControls / Switching works under Win7/.NET 4.5 but not under Windows 8.1/.NET 4.5.1 -
c# - WPF: Two TabControls / Switching works under Win7/.NET 4.5 but not under Windows 8.1/.NET 4.5.1 -
i've got window 2 tabcontrols. 1 left-aligned, other right-aligned. headers of tabcontrols aligned in top row.
whenever click tabitem, other tabcontrol unfocused.
that works fine on development pc (windows 7, .net framework 4.5).
however, when execute under pc windows 8.1 (.net 4.5.1), can not switch right-aligned tabcontrol. when click on tabitem within it, nil @ happens.
xaml of mainwindow:
<window x:class="tabgroupproblem.mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" title="mainwindow" height="350" width="525" loaded="window_loaded"> <grid> <tabcontrol gotfocus="tabcontrol_gotfocus" x:name="c1"> <tabitem header="one">h</tabitem> <tabitem header="two">i</tabitem> </tabcontrol> <tabcontrol gotfocus="tabcontrol_gotfocus_1" x:name="c2"> <tabcontrol.resources> <style targettype="{x:type tabpanel}"> <setter property="horizontalalignment" value="right" /> </style> </tabcontrol.resources> <tabitem header="three">j</tabitem> <tabitem header="four">k</tabitem> </tabcontrol> </grid> </window>
event handlers:
private void tabcontrol_gotfocus(object sender, routedeventargs e) { // c1 foreground system.windows.controls.grid.setzindex(c2, -1); c2.selectedindex = -1; } private void tabcontrol_gotfocus_1(object sender, routedeventargs e) { // c2 foreground system.windows.controls.grid.setzindex(c2, 1); c1.selectedindex = -1; } private void window_loaded(object sender, routedeventargs e) { system.windows.controls.grid.setzindex(c1, 0); system.windows.controls.grid.setzindex(c2, -1); c2.selectedindex = -1; }
why happen, , can against it?
edit: switched target framework .net 4.5.1 on development pc. switching between tabcontrols still works on pc (and still not on windows 8.1 pc)
you placing 2 tabcontrols straight on each other, still expect able focus 1 underneath. happens work in win7, appear windows 8 uses different command template potentially eats mouse clicks on "blank" bit of tabpanel.
maybe it's adding transparent brush, seek simple:
<tabcontrol.resources> <style targettype="{x:type tabpanel}"> <setter property="background" value="{x:null}" /> </style> </tabcontrol.resources>
however, suspect easier ditch tab command , create styled buttons yourself?
c# .net wpf
Comments
Post a Comment