Sign In|Join
Home/Silverlight.NET Forums/General Silverlight Programming/Programming with .NET - General/How to specify the height and width of Canvas by percentage.?
Last post Jan 09, 2008 02:38 AM by mchlsync
Star
14968 Points
2799 Posts
Jan 09, 2008 02:38 AM | LINK
Try the following steps ~
1. Set [Scriptable] in Page.xaml
2. Add the constructor in Page.xaml
public Page() { try { WebApplication.Current.RegisterScriptableObject ("EntryPoint", this); } catch ( Exception ex ) { } }
3. Update this function in TestPage.html.js. (Take a look at bold)
document.body.onload = function() { var silverlightControl = document.getElementById('SilverlightControl'); if (silverlightControl) silverlightControl.focus(); var control = document.getElementById("SilverlightControl"); control.Content.EntryPoint.InitResolution(screen.width, screen.height); }
4. Add this function in Page.xaml
double _width; double _height; [Scriptable] public void InitResolution(string width,string height) { _width = Convert.ToDouble(width); _height = Convert.ToDouble(height); this.SetValue (WidthProperty, _width); }
then, it will work.
mchlSync
Star
14968 Points
2799 Posts
Re: How to specify the height and width of Canvas by percentage.?
Jan 09, 2008 02:38 AM | LINK
Try the following steps ~
1. Set [Scriptable] in Page.xaml
2. Add the constructor in Page.xaml
public Page()
{
try
{
WebApplication.Current.RegisterScriptableObject ("EntryPoint", this);
}
catch ( Exception ex )
{
}
}
3. Update this function in TestPage.html.js. (Take a look at bold)
document.body.onload = function() {
var silverlightControl = document.getElementById('SilverlightControl');
if (silverlightControl)
silverlightControl.focus();
var control = document.getElementById("SilverlightControl");
control.Content.EntryPoint.InitResolution(screen.width, screen.height);
}
4. Add this function in Page.xaml
double _width;
double _height;
[Scriptable]
public void InitResolution(string width,string height)
{
_width = Convert.ToDouble(width);
_height = Convert.ToDouble(height);
this.SetValue (WidthProperty, _width);
}
then, it will work.
Regards,
Michael Sync
Silverlight MVP
Blog : http://michaelsync.net