SilverLight?
「dayGrid」として宣言したGridコントロールがあります。
for (int i = 1; i < 28; i++)
{
//dayGridコントロール縦方向分割
RowDefinition row = new RowDefinition();
row.MinHeight = 30;
row.MaxHeight = 50;
dayGrid.RowDefinitions.Add(row);
}
for (int i = 1; i < 28; i++)
{
//TextBlockコントロール作成
TextBlock tb = new TextBlock();
tb.Name = "tb" + i.ToString();
tb.Text = i.ToString();
//Borderコントロール作成
Border textBorder = new Border();
textBorder.Name = "textborder" + i.ToString();
//TextBlockコントロールをBorderに追加
textBorder.Child = tb;
textBorder.BorderBrush = new SolidColorBrush(Colors.Blue);
textBorder.BorderThickness = new Thickness(0, 0, 0, 1);
textBorder.Cursor = System.Windows.Input.Cursors.Hand;
//Borderコントロールは分割したGridの行に所属させる
textBorder.SetValue(Grid.RowProperty, (i - 1));
//BorderコントロールをdayGridに追加
dayGrid.Children.Add(textBorder);
}
this.Dispatcher.BeginInvoke(delegate()
{
...
}
borderの右下の処にPopupコントロールを表示させたい場合、次のソースコードのように、設定できます。
GeneralTransform transform = border.TransformToVisual(Application.Current.RootVisual); Point point = transform.Transform(new Point(0, border.ActualHeight)); this.detailPopup.VerticalOffset = point.Y - 20; this.detailPopup.HorizontalOffset = point.X + 20;
App.xaml.csファイルの「App」クラスの「Application_Startup」イベントからよみこめます。 ソースコード例(ひどいコードを書いてます。):
private void Application_Startup(object sender, StartupEventArgs e)
{
object obj = e.InitParams.["setting1"]
}
HTML 側の設定例:
<object data="data:application/x-silverlight-2,"
type="application/x-silverlight-2" style="height: 262px; width: 55%">
<param name="source" value="ClientBin/Calendar.xap"/>
<param name="onError" value="onSilverlightError" />
<param name="background" value="white" />
<param name="minRuntimeVersion" value="4.0.50401.0" />
<param name="autoUpgrade" value="true" />
<param name="initParams" value="setting1=1,setting2=2" />
<a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50401.0" style="text-decoration:none">
<img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Microsoft Silverlight の取得" style="border-style:none"/>
</a>
</object>
System.Windows.Browser名前空間を利用します。
HtmlDocument htmlDoc = HtmlPage.Document;
HtmlElement htmlEl = htmlDoc.GetElementById("input");
htmlEl.SetProperty("disabled", false);
htmlEl.SetAttribute("value", "渡す値");
ResourceDictionary定義ファイルの例:
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Assets/Styles.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style x:Key="Blurred" TargetType="Button">
<Setter Property="Effect">
<Setter.Value>
<BlurEffect Radius="8" />
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
呼び出す例:
link.Style = Application.Current.Resources["Blurred"] as Style;
ScorllBarコントロールを利用するではなく、ScrollViewerコントロールを利用します。
<ScrollViewer Name="dateSelectorScorll" ScrollViewer.HorizontalScrollBarVisibility="Auto" Margin="0,-5,6,0"> <Grid Name="dayGrid" Width="auto" Margin="0,0,0,0"> </Grid> </ScrollViewer>
Silverlight関連するリソースのダウンロードURL http://msdn.microsoft.com/ja-jp/silverlight/bb187452.aspx
「Microsoft Silverlight 4 Tools for Visual Studio 2010」の中にSDKが含まれているので、これだけインストールすれば Silverlight SDK もインストールされますが、Silverlight 4 開発者向けランタイムを別途インストールする必要があります。
開発者向けランタイムがインストールされていない場合、デバッグ開始すると、下記のようなエラーが発生します。 デバッグを開始できません。Silverlight Developer Runtimeがインストールされていません。一致するバージョンをインストールしてください。
Silverlight ToolkitのCodePlexサイトURL: http://silverlight.codeplex.com/
自動生成されたWebContextクラスは、そのままプロジェクトにコピーしたら、利用できる
RIAサービスによって、WebContext クラスを生成します。デフォルトでは、「Silverlight Business Application」のプロジェクトを作成すると、自動的に生成されます。
borderの右下の処にPopupコントロールを表示させたい場合、次のソースコードのように、設定できます。
GeneralTransform transform = border.TransformToVisual(Application.Current.RootVisual); Point point = transform.Transform(new Point(0, border.ActualHeight)); this.detailPopup.VerticalOffset = point.Y - 20; this.detailPopup.HorizontalOffset = point.X + 20;
コントロールを格納するためのページ(navigation:Page)ユーザーコントロール(UserControl)のサイズを設定するのは、Width、HeightではなくDesignHeight、DesignWidthで設定します、Width、Heightで設定する場合、ページまたはユーザーコントロールのサイズが固定になって、ブラウザのサイズの変更によって、変更できません。
ページまたはユーザーコントロール内のコントロールはブラウザのサイズによって、変更させたい時、水平・垂直場合よってコントロールのHorizontalAlignmentまたはVerticalAlignmentプロパティを「Stretch」に設定します。コントロールのサイズを変更させたくない時、ニーズに合わせて「Stretch」以外の値で設定します。
下記のソースコードは、色変化するアニメーションの持続時間を1000ミリ秒に設定した例です。
Storyboard x:Name="storyboard1">
<ColorAnimation Storyboard.TargetName="xxx" Storyboard.TargetProperty="Color" From="#FFD7E6F3" To="White" Duration="0:0:0.1" /> </Storyboard>
Style x:Key="RoundCloseButton" TargetType="Button">
<Setter Property="HorizontalAlignment" Value="Center"/> <Setter Property="VerticalAlignment" Value="Center"/> <Setter Property="Width" Value="25"/> <Setter Property="Height" Value="30"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate> <Grid> <vsm:VisualStateManager.VisualStateGroups> <vsm:VisualStateGroup x:Name="CommonStates"> <vsm:VisualState x:Name="Normal"/> <vsm:VisualState x:Name="MouseOver"> <Storyboard> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="glow" Storyboard.TargetProperty="(UIElement.Opacity)"> <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="1"/> </DoubleAnimationUsingKeyFrames> </Storyboard> </vsm:VisualState> </vsm:VisualStateGroup> </vsm:VisualStateManager.VisualStateGroups>
<Border Width="22" x:Name="glow" Height="22" CornerRadius="15" ToolTipService.ToolTip="Sulge (Esc)">
<TextBlock Foreground="#222" TextAlignment="center" Text="r" FontSize="11" VerticalAlignment="center" FontFamily="Webdings"/>
<Border.Background>
<RadialGradientBrush GradientOrigin=".3, .3">
<GradientStop Color="#FFF" Offset=".15"/>
<GradientStop Color="DarkRed" Offset="1"/>
</RadialGradientBrush>
</Border.Background>
</Border>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Gridコントロールを利用して、表構造を作成した状態で、GridSplitterコントロールを利用して、Gridの行・列のサイズを変更することができます。 一度リサイズしたGridの高さ・幅を初期状態に戻るのは、下記にような、Gridの行の高さ・幅をもう一回設定すれば戻れます。
//初期状態に戻る //「28」はGridの行のデフォルトの高さ this.GridLayout.RowDefinitions[1].Height = new GridLength(28);
コメント:
0
e[NȂECir Yahoo yV LINEf[^[Ōz500~`I
z[y[W ̃NWbgJ[h COiq@COsیI COze