Skip to main content

Microsoft Silverlight

Answered Question Cursors don't work in tabs when setting parentRSS Feed

(0)

caseynshan83
caseynsh...

Member

Member

20 points

99 Posts

Cursors don't work in tabs when setting parent

First, the cursors not working across user controls is very tough.

 Second. even if you set them on the parent, they don't work on tab items.

 

In order to use the wait cursor.. i have to go through every tab and set it's cursor, then i have to go through every tab, get it's content and set it's cursor... that's not realistic...

this.Cursor = Cursors.Wait;

((EGIBasins)Application.Current.RootVisual).Cursor = Cursors.Wait;

((EGIBasins)Application.Current.RootVisual).tc.myTabControl.Cursor = Cursors.Wait;

((EGIBasins)Application.Current.RootVisual).tc.Home.Cursor = Cursors.Wait;

((OpenPage)((EGIBasins)Application.Current.RootVisual).tc.Home.Content).Cursor = Cursors.Wait;

 

Yi-Lun Luo - MSFT
Yi-Lun L...

All-Star

All-Star

25052 points

2,747 Posts

Re: Cursors don't work in tabs when setting parent

Hello, can you post some code? Do you have a series of TabItems in a TabControl, and you want to set cursor to wait on all of them? If so, you simply need to set the TabControl's Cursor to Wait. Note in Beta2, this approach may not affect the TabItem's header (only the TabItem's body is affected). This should have been fixed internally already. But I can't 100% assure you at this time...

shanaolanxing - I'll transfer to the Windows Azure team, and will have limited time to participate in the Silverlight forum. Apologize if I don't answer your questions in time.

caseynshan83
caseynsh...

Member

Member

20 points

99 Posts

Re: Cursors don't work in tabs when setting parent

At actually seems to be the opposite, it works on the tabitem header, but no where else.

<UserControl xmlns:my1="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls.Extended" xmlns:my="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Extended" x:Class="testTabs.Page"

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

Width="450" Height="300" Loaded="UserControl_Loaded" x:Name="UserControl1">

<Grid x:Name="LayoutRoot" Background="White" >

<StackPanel>

<StackPanel Orientation="Horizontal" Margin="5">

<Button Content="Study" Click="Button_Click_3" ></Button>

</StackPanel>

<Rectangle Height="50"></Rectangle>

<my:TabControl x:Name="MyTabControl" >

<my:TabItem x:Name="Home" Header="Home" >

 

</my:TabItem>

<my:TabItem x:Name="StudyList" Header="StudyList" >

 

</my:TabItem>

<my:TabItem x:Name="Study" Header="Study" Width="100">

 

</my:TabItem>

<my:TabItem x:Name="Map" Header="Map" Width="100" >

 

</my:TabItem>

 

</my:TabControl>

</StackPanel>

</Grid>

 

</UserControl>

 

 

 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Net;

using System.Windows;

using System.Windows.Controls;

using System.Windows.Documents;

using System.Windows.Input;

using System.Windows.Media;

using System.Windows.Media.Animation;

using System.Windows.Shapes;

using System.Windows.Threading;

namespace testTabs

{

public partial class Page : UserControl

{

public Page()

{

InitializeComponent();

}

 

public int iClick = 1;

 

private void Button_Click(object sender, RoutedEventArgs e)

{

int iTabIndex = MyTabControl.SelectedIndex;

}

private void MyTabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)

{

if (MyTabControl != null)

{

int iTabIndex = MyTabControl.SelectedIndex;

}

}

DispatcherTimer eventTimer;

bool eventTimerRunning;

private void Button_Click_3(object sender, RoutedEventArgs e)

{

 

this.Cursor = Cursors.Wait;

MyTabControl.Cursor = Cursors.Wait;

eventTimer = new DispatcherTimer();

eventTimer.Interval = new TimeSpan(0, 0, 0, 0, 5000); // tick every 500 milliseconds

eventTimer.Tick += new EventHandler(eventTimer_Tick2);eventTimerRunning = true;

eventTimer.Start();

if (Study.Width == 100)

Study.Width = 0;

else

Study.Width = 100;

TextBlock tb = new TextBlock();

tb.Height = 200;

tb.Width = 200;

tb.Text =
"THis is a test";SilverlightControl1 sc = new SilverlightControl1();

Study.Content = sc;

 

 

 

}

 

 

private void eventTimer_Tick2(object sender, EventArgs e)

{

eventTimerRunning =
false;

eventTimer.Stop();

this.Cursor = Cursors.Arrow;MyTabControl.Cursor = Cursors.Arrow;

}

 

private void UserControl_Loaded(object sender, RoutedEventArgs e)

{

 

StudyList.Width =0;

Study.Width = 0;

Map.Width = 0;

 

}

}

}

Yi-Lun Luo - MSFT
Yi-Lun L...

All-Star

All-Star

25052 points

2,747 Posts

Answered Question

Re: Re: Cursors don't work in tabs when setting parent

Yes, sometimes the cursor doesn't behavior correctly in Beta2. But when I tested your application in an internal newer build, it always worked fine. So hopefully this issue has already been fixed.

shanaolanxing - I'll transfer to the Windows Azure team, and will have limited time to participate in the Silverlight forum. Apologize if I don't answer your questions in time.
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities