Skip to content

Instantly share code, notes, and snippets.

@Rolias
Created June 20, 2011 18:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rolias/1036178 to your computer and use it in GitHub Desktop.
Save Rolias/1036178 to your computer and use it in GitHub Desktop.
WPF User Control with FlowDocument problem, where text won't wrap
<UserControl x:Class="Its9202Gui.View.InstrumentView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:Controls="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit.Extended"
mc:Ignorable="d"
d:DesignHeight="465"
d:DesignWidth="986" xmlns:my="clr-namespace:Its9202Gui.View">
<UserControl.Resources>
<Style x:Key="myButtonStyle">
<Setter Property="Control.VerticalAlignment"
Value="Center" />
<Setter Property="Control.Margin"
Value="12,0,0,0" />
<Setter Property="Control.Width"
Value="75" />
</Style>
<Style x:Key="myFlowDoc">
<Setter Property="Control.Padding"
Value="0" />
<Setter Property="FlowDocumentScrollViewer.IsToolBarVisible"
Value="True" />
<Setter Property="Control.MinHeight"
Value="150" />
<Setter Property="Control.BorderBrush"
Value="SteelBlue" />
<Setter Property="Control.BorderThickness"
Value="2" />
<Setter Property="Control.VerticalAlignment"
Value="Stretch" />
</Style>
</UserControl.Resources>
<Grid Margin="6"
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition Height="60" />
<RowDefinition Height="67" />
<RowDefinition Height="152" />
<RowDefinition Height="25" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<GroupBox Header="Direct Commands">
<StackPanel Orientation="Horizontal">
<ComboBox ItemsSource="{Binding ScpiCommands, Mode=OneTime}"
Text="{Binding ScpiCommandString}"
HorizontalAlignment="Stretch"
Margin="12,0,0,0"
VerticalAlignment="Center"
MinWidth="175"
IsEditable="True" />
<my:TcpSettingsView Height="0" Width="0" />
<Button Command="{Binding SendTcpCommand}"
Style="{StaticResource myButtonStyle}">
Send
</Button>
<my:TcpSettingsView Height="0" x:Name="tcpSettingsView1" Width="1" />
<Button Command="{Binding ReceiveDataCommand}"
Style="{StaticResource myButtonStyle}">
Receive
</Button>
</StackPanel>
</GroupBox>
<GroupBox Header="Debug"
Grid.Column="1">
<StackPanel Orientation="Horizontal">
<my:TcpSettingsView Height="0" x:Name="tcpSettingsView2" Width="0" />
<ComboBox ItemsSource="{Binding DebugLevels, Mode=OneTime}"
Text="{Binding DebugLevelString}"
HorizontalAlignment="Stretch"
Margin="12,0,0,0"
VerticalAlignment="Center"
MinWidth="175"
IsEditable="False"
SelectedIndex="0"/>
<my:TcpSettingsView Height="1" x:Name="tcpSettingsView3" Width="0" />
<Button Command ="{Binding SetDebugLevelCommand}"
Content="Set"
Style="{StaticResource myButtonStyle}" />
</StackPanel>
</GroupBox>
<GroupBox Grid.Row="1"
Header="Settings"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Grid.RowSpan="2"
IsEnabled="{Binding SettingsGroupBoxIsEnabled}">
<Grid Height="189"
Width="285">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Orientation="Vertical"
VerticalAlignment="Top"
Margin="6,6,6,0" >
<TextBlock HorizontalAlignment="Left">Phase</TextBlock>
<Controls:IntegerUpDown Value="{Binding Phase}"
Height="23"
Width="100"
HorizontalAlignment="Left"
Maximum="65535">
</Controls:IntegerUpDown>
</StackPanel>
<StackPanel Grid.Row="1" Orientation="Vertical" Margin="6,0" >
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,6">Frequency Switch</TextBlock>
<Button
Command="{Binding SwitchFreqCommand}"
Height="64"
Width="128"
HorizontalAlignment="Left"
VerticalAlignment="Top"
BorderThickness="0"
Background="Transparent">
<Image Source="{Binding Path=SwitchSourceImagePath}" />
</Button>
</StackPanel>
<!-- Lock Detect-->
<StackPanel Grid.Row="1" Grid.Column="1" Orientation="Vertical" Margin="6,0" >
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,6">Lock Detect</TextBlock>
<Image
Source="{Binding LockDetectImage}"
Height="32"
Width="32"
HorizontalAlignment="Center"
VerticalAlignment="Top" />
</StackPanel>
</Grid>
</GroupBox>
<!-- Error Message And Clear Button-->
<TextBlock Grid.Row="3"
FontWeight="Bold">
Instrument Error Messages
</TextBlock>
<Button Grid.Row="3"
Command="{Binding ClearErrorsCommand}"
VerticalAlignment="Center"
Height="23"
Margin="0,2,16,0"
Style="{StaticResource myButtonStyle}"
HorizontalAlignment="Right">
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Stretch"
Width="70"
IsHitTestVisible="False">
<Image Source="../Artwork/RedExit.png"
Height="16"
HorizontalAlignment="Left"
IsHitTestVisible="False" />
<TextBlock Margin="6,0,0,0"
Text="Clear" />
</StackPanel>
</Button>
<!-- Error Message Viewer -->
<FlowDocumentScrollViewer Style="{StaticResource myFlowDoc}"
Grid.Row="4" HorizontalScrollBarVisibility="Visible" Margin="0,0,6,-1">
<FlowDocument IsColumnWidthFlexible="True">
<Paragraph TextAlignment="Left"
TextIndent="-16"
LineHeight="12">
<ItemsControl ItemsSource="{Binding UnderlyingInstrument.ErrorMessages, Mode=OneWay}" />
<Run Text="{Binding /, Mode=OneWay}" />
</Paragraph>
</FlowDocument>
</FlowDocumentScrollViewer>
<!-- Information Message Text and Buttons-->
<TextBlock FontWeight="Bold"
Grid.Column="1"
Grid.Row="3">
Command Result Messages
</TextBlock>
<Button Grid.Row="3"
Grid.Column="1"
Command="{Binding GetErrorsCommand}"
Height="23"
Width="90"
Margin="0,2,106,0"
Style="{StaticResource myButtonStyle}"
HorizontalAlignment="Right">
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Stretch"
IsHitTestVisible="False"
Width="90">
<Image Source="../Artwork/Download16.png"
Height="16"
HorizontalAlignment="Left"
IsHitTestVisible="False" />
<TextBlock Margin="6,0,0,0"
Text="Cmd. Errors" />
</StackPanel>
</Button>
<Button Grid.Column="1"
Command="{Binding ClearInfoCommand}"
Grid.Row="3"
Height="23"
HorizontalAlignment="Right"
Margin="0,2,16,0"
Style="{StaticResource myButtonStyle}">
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Stretch"
Width="73"
IsHitTestVisible="False">
<Image Source="../Artwork/RedExit.png"
Height="16"
HorizontalAlignment="Left"
IsHitTestVisible="False" />
<TextBlock Margin="6,0,0,0"
Text="Clear" />
</StackPanel>
</Button>
<FlowDocumentScrollViewer Style="{StaticResource myFlowDoc}"
Grid.Row="4"
Grid.Column="1"
HorizontalAlignment="Left">
<FlowDocument >
<Paragraph LineHeight="12" >
<ItemsControl ItemsSource="{Binding ReceivedData, Mode=OneWay}" />
<TextBlock TextWrapping="Wrap" Text="{Binding /, Mode=OneWay}" />
</Paragraph>
</FlowDocument>
</FlowDocumentScrollViewer>
<!--<Run Text="{Binding /, Mode=OneWay}" />-->
</Grid>
</UserControl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment