Monday, March 26, 2012
Q: What is XBAP?
4:32 PM
XBAP stands for XAML Browser
Application. XBAP allows for WPF applications to be used inside a browser. The .NET
framework is required to be installed on the client system. Hosted applications
run in a partial trust sandbox environment. They are not given full access to
the computer's resources and not all of WPF functionality is available.
WPF supports the creation of
applications that run directly in a web browser. (So will WPF/E,
when it is released.) They are called XAML Browser Applications (XBAPs), and have
a .xbap file extension.
The power of this WPF support is
that the exact same programming model is used for a XAML
Browser Application as for a standard Windows application. Therefore, creating
an XBAP isn’t much different than creating a standard Windows
application. The main differences are as follows:
. Not all features in WPF or the .NET
Framework are accessible (by default).
. Navigation is integrated into the
browser (for Internet Explorer 7 or later).
. Deployment is handled differently.
Q: What are possible ways to implement distributed applications in .NET?
4:32 PM
.NET Remoting and ASP.NET Web
Services.
Thursday, March 15, 2012
Q: Where’s the entry point in WPF application?
12:28 PM
When you create a WPF Windows
Application in Visual Studio, the generated project has no Main method, yet it
still runs as expected! In fact, even attempting to add a Main method
gives a compilation error telling you that it is already defined.
Application is special-cased when it is compiled from XAML, because Visual Studio assigns
the XAML file a Build Action of ApplicationDefinition. This causes a Main method to be
autogenerated.
gives a compilation error telling you that it is already defined.
Application is special-cased when it is compiled from XAML, because Visual Studio assigns
the XAML file a Build Action of ApplicationDefinition. This causes a Main method to be
autogenerated.
Q: What unit of measurement is used by WPF?
12:27 PM
All
absolute measurements, such as the numbers used in this section’s size-related
properties,
are specified in device-independent pixels. These “logical pixels” are meant to represent
1/96th of an inch, regardless of the screen’s DPI setting. Note that device-independent
pixels are always specified as double values, so they can be fractional.
The exact measurement of 1/96th of an inch isn’t important, although it was chosen
because on a typical 96 DPI display, one device-independent pixel is identical to one physical
pixel. Of course, the notion of a true “inch” depends on the physical display device. If an
application draws a one-inch line on my laptop screen, that line will certainly be longer than
one inch if I hook up my laptop to a projector!
are specified in device-independent pixels. These “logical pixels” are meant to represent
1/96th of an inch, regardless of the screen’s DPI setting. Note that device-independent
pixels are always specified as double values, so they can be fractional.
The exact measurement of 1/96th of an inch isn’t important, although it was chosen
because on a typical 96 DPI display, one device-independent pixel is identical to one physical
pixel. Of course, the notion of a true “inch” depends on the physical display device. If an
application draws a one-inch line on my laptop screen, that line will certainly be longer than
one inch if I hook up my laptop to a projector!
Q: How can I make TextBox support multiple lines of text?
12:26 PM
Setting AcceptsReturn to true allows
users to press the Enter key to create a new line of
text. Note that TextBox always supports multiple lines of text programmatically. If its Text is
set to a string containing NewLine characters, it displays the multiple lines regardless of the
value of AcceptsReturn. Also, the multiline support is completely independent from text
wrapping. Text wrapping only applies to individual lines of text that are wider than the
TextBox.
text. Note that TextBox always supports multiple lines of text programmatically. If its Text is
set to a string containing NewLine characters, it displays the multiple lines regardless of the
value of AcceptsReturn. Also, the multiline support is completely independent from text
wrapping. Text wrapping only applies to individual lines of text that are wider than the
TextBox.
Q: How can I get ListBox to scroll smoothly?
12:25 PM
Sorting can be done via a mechanism
on the ItemsCollection object, so it applies equally to
all ItemsControls. ItemsCollection has a SortDescriptions property
that can hold any number of System.ComponentModel.SortDescription
instances. Each SortDescription describes which property of the
items should be used for sorting and whether the sort is ascending or
descending. For example, the following code sorts a bunch of ContentControl
items based on their Content property:
// Clear any existing sorting first
myItemsControl.Items.SortDescriptions.Clear();
// Sort by the Content property
myItemsControl.Items.SortDescriptions.Add(
new SortDescription(“Content”,
ListSortDirection.Ascending));
Q: How can I get ListBox to scroll smoothly?
12:24 PM
By default, ListBox scrolls on an
item-by-item basis. Because the scrolling is based on each
item’s height, it can look quite choppy if you have large items. If you want smooth scrolling,
such that each scrolling action shifts the items by a small number of pixels regardless of
their heights, the easiest solution is to set the ScrollViewer.CanContentScroll attached
property to false on the ListBox.
Be aware, however, that by making this change you lose ListBox’s virtualization functionality.
Virtualization refers to the optimization of creating child elements only when they become
visible on the screen. Virtualization is only possible when using data binding to fill the
control’s items, so setting CanContentScroll to false can negatively impact the performance
of data-bound scenarios only.
item’s height, it can look quite choppy if you have large items. If you want smooth scrolling,
such that each scrolling action shifts the items by a small number of pixels regardless of
their heights, the easiest solution is to set the ScrollViewer.CanContentScroll attached
property to false on the ListBox.
Be aware, however, that by making this change you lose ListBox’s virtualization functionality.
Virtualization refers to the optimization of creating child elements only when they become
visible on the screen. Virtualization is only possible when using data binding to fill the
control’s items, so setting CanContentScroll to false can negatively impact the performance
of data-bound scenarios only.
Subscribe to:
Posts (Atom)