How can I use the BlockUIContainer element to host UIElement objects within Flow content ?

A BlockUIContainer is a flow content element that allows UIElement to be hosted inside the flow content. This can be done as follows. [XAML] <FlowDocument ColumnWidth=’400′> <Section Background=’GhostWhite’> <Paragraph> A UIElement element may be embedded directly in flow content by enclosing it in a BlockUIContainer element. </Paragraph> <BlockUIContainer> <Button>Click me!</Button> </BlockUIContainer> <Paragraph> The BlockUIContainer element may host no more than one top-level UIElement. However, other UIElements may be nested within the UIElement contained by an BlockUIContainer element. For example, a StackPanel can be used to host multiple UIElement elements within a BlockUIContainer element. </Paragraph> <BlockUIContainer> <StackPanel> <Label Foreground=’Blue’>Choose a value:</Label> <ComboBox> <ComboBoxItem IsSelected=’True’>a</ComboBoxItem> <ComboBoxItem>b</ComboBoxItem> <ComboBoxItem>c</ComboBoxItem> </ComboBox> <Label Foreground =’Red’>Choose a value:</Label> <StackPanel> <RadioButton>x</RadioButton> <RadioButton>y</RadioButton> <RadioButton>z</RadioButton> </StackPanel> <Label>Enter a value:</Label> <TextBox> A text editor embedded in flow content. </TextBox> </StackPanel> </BlockUIContainer> </Section> </FlowDocument>

What built-in commands are defined in the WPF framework?

WPF provides a library of common commands, which include ApplicationCommands ComponentCommands NavigationCommands MediaCommands EditingCommands Sample code given below: [XAML] <Window x:Class=’SDKSamples.Window1′ xmlns=’http://schemas.microsoft.com/winfx/2006/xaml/presentation’ xmlns:x=’http://schemas.microsoft.com/winfx/2006/xaml’ Title=’MenuItemCommandTask’> <DockPanel> <Menu DockPanel.Dock=’Top’> <MenuItem Command=’ApplicationCommands.Paste’ Width=’75’ /> </Menu> <TextBox BorderBrush=’Black’ BorderThickness=’2′ Margin=’25’ TextWrapping=’Wrap’> The MenuItem will not be enabled until this TextBox gets keyboard focus </TextBox> </DockPanel> <Window>

What is XBAP?

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.

How can I throw my events asynchronously?

You can do so by calling BeginInvoke on your delegates. Unfortunately, you can’t call BeginInvoke() on the event member directly. You can invoke BeginInvoke()only if the delegate’s internal list of sink callbacks (actually other delegates) has only one target in it. If you have more than one, the delegate throws an exception. The workaround is to iterate over the event delegate internal invocation list, calling BeginInvoke() on everyone of them. You access the internal list using the GetInvocationList() method. Here is an example: public delegate void NumberChangedDelegate(int num); public class MySource { public event NumberChangedDelegate m_NumberChangedEvent; public void FireEventAsynch(int num) { Delegate[] delegates = m_NumberChangedEvent.GetInvocationList(); foreach (Delegate del in delegates) { NumberChangedDelegate sink = (NumberChangedDelegate) del; sink.BeginInvoke(num, null, null); } } public void FireEvent(int num) { m_NumberChangedEvent(num); } } From Juval Löwy at www.idesign.net; from his article in the .Net Insight online magazine at www.fawcette.com.