I have a WPF app with a few checkboxes. I am able to set the IsChecked property in XAML, however, when I go to set it programatically, there is no such property. From everything I read, this property (IsChecked) is how I should be setting the value.
The XAML is below:
<Window x:Class="FC.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="FCSX Utility" SizeToContent="WidthAndHeight" ResizeMode="NoResize" Background="WhiteSmoke" Loaded="Window_Loaded">
<Window.InputBindings>
<KeyBinding Key="N"
Modifiers="Control"
Command="ApplicationCommands.Properties" />
<KeyBinding Key="S"
Modifiers="Control"
Command="ApplicationCommands.Print" />
<KeyBinding Key="L"
Modifiers="Control"
Command="ApplicationCommands.PrintPreview" />
<KeyBinding Key="I"
Modifiers="Control"
Command="ApplicationCommands.CancelPrint" />
</Window.InputBindings>
<TabControl Name="tcTabs" SelectionChanged="tcTabs_SelectionChanged">
<TabItem Name="tciClock" Header="Clock">
<StackPanel Name="spClock" Orientation="Vertical" Margin="0">
<Label FontWeight="Bold">Clock</Label>
<StackPanel Orientation="Vertical" Margin="10">
<StackPanel Orientation="Horizontal" Margin="10">
<Label>Start Time</Label>
<ComboBox Name="cbHour"></ComboBox>
<Label>:</Label>
<ComboBox Name="cbMinute"></ComboBox>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="10">
<Label>Day Of Week</Label>
<ComboBox Name="cbClockDay"></ComboBox>
</StackPanel>
<Button Name="btnSetClockSystemTime" Click="btnSetClockSystemTime_Click">Set To Current System Time</Button>
</StackPanel>
<StackPanel Orientation="Horizontal">
<Label Name ="ckbAlarm1" FontWeight="Bold">Alarm 1</Label>
<CheckBox VerticalAlignment="Center" IsChecked="False"></CheckBox>
</StackPanel>
<StackPanel Name="spAlarm1" Orientation="Vertical" Margin="10">
<StackPanel Orientation="Horizontal" Margin="10">
<Label>Start Time</Label>
<ComboBox Name="cbAlarm1StartHour"></ComboBox>
<Label>:</Label>
<ComboBox Name="cbAlarm1StartMinute"></ComboBox>
<Label>Duration</Label>
<ComboBox Name="cbAlarm1DurationHour"></ComboBox>
<Label>hrs</Label>
<ComboBox Name="cbAlarm1DurationMinute"></ComboBox>
<Label>min</Label>
</StackPanel>
<Label>Days:</Label>
<StackPanel Orientation="Horizontal" Margin="10">
<CheckBox Name="ckbAlarm1Mon">Mon</CheckBox>
<CheckBox Name="ckbAlarm1Tues">Tue</CheckBox>
<CheckBox Name="ckbAlarm1Wed">Wed</CheckBox>
<CheckBox Name="ckbAlarm1Thu">Thu</CheckBox>
<CheckBox Name="ckbAlarm1Fri">Fri</CheckBox>
<CheckBox Name="ckbAlarm1Sat">Sat</CheckBox>
<CheckBox Name="ckbAlarm1Sun">Sun</CheckBox>
</StackPanel>
</StackPanel>
<StackPanel Orientation="Horizontal">
<Label FontWeight="Bold">Alarm 2</Label>
<CheckBox Name="ckbAlarm2" VerticalAlignment="Center"></CheckBox>
</StackPanel>
<StackPanel Name="spAlarm2" Orientation="Vertical" Margin="10">
<StackPanel Orientation="Horizontal" Margin="10">
<Label>Start Time</Label>
<ComboBox Name="cbAlarm2StartHour"></ComboBox>
<Label>:</Label>
<ComboBox Name="cbAlarm2StartMinute"></ComboBox>
<Label>Duration</Label>
<ComboBox Name="cbAlarm2DurationHour"></ComboBox>
<Label>hrs</Label>
<ComboBox Name="cbAlarm2DurationMinute"></ComboBox>
<Label>min</Label>
</StackPanel>
<Label>Days:</Label>
<StackPanel Orientation="Horizontal" Margin="10">
<CheckBox Name="ckbAlarm2Mon">Mon</CheckBox>
<CheckBox Name="ckbAlarm2Tues">Tue</CheckBox>
<CheckBox Name="ckbAlarm2Wed">Wed</CheckBox>
<CheckBox Name="ckbAlarm2Thu">Thu</CheckBox>
<CheckBox Name="ckbAlarm2Fri">Fri</CheckBox>
<CheckBox Name="ckbAlarm2Sat">Sat</CheckBox>
<CheckBox Name="ckbAlarm2Sun">Sun</CheckBox>
</StackPanel>
</StackPanel>
<Button>Apply</Button>
</StackPanel>
</TabItem>
<TabItem Name="tciTrigger" Header="Triggering">
<StackPanel Name="spTrigger" Orientation="Vertical">
<StackPanel Orientation="Vertical" Margin="10">
<Label FontWeight="Bold">Trigger Options</Label>
<StackPanel Margin="10">
<Label>Reset Delay</Label>
<StackPanel Orientation="Horizontal">
<TextBox Width="100"></TextBox>
<Label>ms</Label>
</StackPanel>
<Label>Arm Delay</Label>
<StackPanel Orientation="Horizontal">
<TextBox Width="100"></TextBox>
<Label>ms</Label>
</StackPanel>
<Label>Take Delay A</Label>
<StackPanel Orientation="Horizontal">
<TextBox Width="100"></TextBox>
<Label>ms</Label>
</StackPanel>
<Label>Take Delay B</Label>
<StackPanel Orientation="Horizontal">
<TextBox Width="100"></TextBox>
<Label>ms</Label>
</StackPanel>
</StackPanel>
</StackPanel>
<StackPanel Orientation="Vertical" Margin="10">
<Label FontWeight="Bold">Trigger Sources</Label>
<CheckBox>Internal Motion Sensor</CheckBox>
<CheckBox>External Sensor</CheckBox>
</StackPanel>
<StackPanel Orientation="Vertical" Margin="10">
<Label FontWeight="Bold">Pre-Trigger Options</Label>
<CheckBox>Enable Pre-Trigger</CheckBox>
<StackPanel Margin="10">
<RadioButton>Pre-Trigger on Internal</RadioButton>
<RadioButton>Pre-Trigger on External</RadioButton>
<Label>Pre-Tigger Reset Time</Label>
<StackPanel Orientation="Horizontal">
<TextBox Width="100"></TextBox>
<Label>ms</Label>
</StackPanel>
</StackPanel>
</StackPanel>
</StackPanel>
</TabItem>
<TabItem Name="tciDebug" Header="Debug" Visibility="Collapsed">
<StackPanel Orientation="Vertical" Margin="10">
<Label>Command Line Output</Label>
<TextBlock TextWrapping="WrapWithOverflow"></TextBlock>
</StackPanel>
</TabItem>
<TabItem Header="FW Update">
<StackPanel Orientation="Vertical" Margin="10">
<TextBlock Margin="5" FontSize="14">Welcome!</TextBlock>
<TextBlock Margin="5" FontSize="14">This utility is used to update the firmware of your FC device.</TextBlock>
<TextBlock Margin="5" FontSize="14">Please follow the steps below:</TextBlock>
<Border Margin="2" BorderBrush="Black" BorderThickness="1" Background="White">
<StackPanel Orientation="Vertical" Margin="10,10,10,10" Background="White">
<Image Name="imgUpdate" Source="/FC-Update;component/Update.png" Width="450" Margin="10" Visibility="Visible" />
<StackPanel Margin="5" Orientation="Horizontal">
<TextBlock Margin="0,0,15,0" Name="lblStep1">Step 1: Connect your FC to the USB port and place<LineBreak/> the jumper in the right position.</TextBlock>
<TextBlock Name="lblStep1Done" Visibility="Collapsed">[DEVICE DETECTED]</TextBlock>
</StackPanel>
<StackPanel Margin="5" Orientation="Horizontal">
<TextBlock Margin="0,0,15,0" Name="lblStep2">Step 2: Power off the FCand power it back on.<LineBreak/>You should NOT hear any tones but the LED should be lit.<LineBreak/>When done click the 'Continue' button -></TextBlock>
<TextBlock Name="lblStep2Done" Visibility="Collapsed">[DONE]</TextBlock>
<Button Name="btnStep2Continue" Click="btnStep2Continue_Click" Visibility="Hidden" Padding="10,2,10,2" Height="30">Continue</Button>
</StackPanel>
<TextBlock Margin="5" Name="lblStep3">
Step 3: Click 'Choose Firmware Update...', then navigate to the provided .bin firmware update file.<LineBreak/>
After you select the file and click 'Open', the update will start automatically.
</TextBlock>
<Button Name="btnGo" Width="200" Height="30" Margin="10,10,10,5" HorizontalAlignment="Center" HorizontalContentAlignment="Center" IsEnabled="False" Click="btnGo_Click">Choose Firmware Update...</Button>
<TextBlock Name="lblConnect" Foreground="Red" HorizontalAlignment="Center" Visibility="Visible">The 'Choose Firmware Update...' button will only be enabled when<LineBreak/> your FC is connected via the USB cable and has been reset.</TextBlock>
<TextBlock Name="lblPleaseWait" HorizontalAlignment="Center" Visibility="Collapsed" Foreground="OrangeRed" FontWeight="Bold">Please wait...</TextBlock>
<ProgressBar Name="prgMain" Width="200" Height="25" Margin="10,10,10,10" HorizontalAlignment="Center" HorizontalContentAlignment="Center" Visibility="Collapsed" Minimum="0" Maximum="100"></ProgressBar>
<TextBlock Name="lblResetWait" HorizontalAlignment="Center" Visibility="Collapsed" Foreground="Green">The firmware update was downloaded and your device was reset.<LineBreak/>Please keep this window open as we wait to make sure it re-connects...</TextBlock>
<TextBlock Name="lblSuccess" HorizontalAlignment="Center" Visibility="Collapsed" Foreground="Green">The firmware update was successful and your device re-connected!<LineBreak/>Please complete Step 4 and then close this window.</TextBlock>
<TextBlock Margin="5" Name="lblStep4">
Step 4: Once the update completes successfully,<LineBreak/>remove the jumper and unplug the USB cable.
</TextBlock>
<TextBlock Name="lblError" HorizontalAlignment="Center" Visibility="Collapsed" Foreground="Red">The firmware update was NOT successful.</TextBlock>
<TextBlock Name="lblErrorMessage" HorizontalAlignment="Center" Visibility="Collapsed" Foreground="Red" />
<Image Name="imgNoUpdate" Source="/FC-Update;component/NoUpdate.png" Width="450" Margin="10" Visibility="Collapsed" />
<TextBlock Name="lblAllowLuminary" HorizontalAlignment="Center" Visibility="Collapsed" Background="Red" Foreground="White" Margin="10">Will Allow Luminary EPT Devices. Press Ctrl-L Again to Disallow.</TextBlock>
</StackPanel>
</Border>
</StackPanel>
</TabItem>
</TabControl>
</Window>
if (Regex.Matches(alarm1Data.ToString(), "ALARM 1 DISABLED").Count == 1)
{
spAlarm1.IsEnabled = false;
// ckbAlarm1.IsChecked = false; // <--- property not found
}
<Label Name ="ckbAlarm1" FontWeight="Bold">Alarm 1</Label>
ckbAlarm1 is a LABEL !!
I'm using Microsoft Visual C# 2010 Express and had the same problem, but with a different solution. The correct code for this platform is:
this.checkBoxDebugMode.Checked = World.Setup.Debug;
instead of
this.checkBoxDebugMode.IsChecked = World.Setup.Debug;
IsChecked is not a valid property here, but it's what you find when you look it up.
Related
I'm using a grid view control in my uwp application and each grid view item contains a grid and a stackpanel. I want to make only grid to be clickable instead on the complete grid view item.
Here is my grid view code
<GridView
Grid.Row="1"
ItemsSource="{x:Bind ViewData}"
ScrollViewer.VerticalScrollBarVisibility="Hidden"
Margin="130,40,130,40">
<GridView.ItemTemplate>
<DataTemplate x:DataType="data:ViewArr">
<StackPanel Margin="50,25,50,25" >
<Grid Height="120" Width="120">
<Image
Source="assets/images/icons/check_my_blue.png"
Height="40"
Width="40"
Canvas.ZIndex="99"
Margin="80,0,0,80">
</Image>
<Canvas>
<Ellipse
Height="120"
Width="120"
Fill ="{x:Bind profile_color , FallbackValue='#00000'}"
StrokeThickness="3"
Stroke="Black" >
</Ellipse>
</Canvas>
<TextBlock
Text="{x:Bind profile_name}"
VerticalAlignment="Center"
HorizontalAlignment="Center"
FontSize="28"
Foreground="White">
</TextBlock>
</Grid>
<StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,10,0,0">
<TextBlock Text="{x:Bind first_name}" FontSize="16" FontWeight="Bold" ></TextBlock>
<TextBlock Text="{x:Bind last_name}" FontSize="16" FontWeight="Bold"></TextBlock>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,10,0,0">
<TextBlock Text="Today - " FontSize="14" FontWeight="Bold" Foreground="Gray" Margin="0,0,5,0"></TextBlock>
<TextBlock Text="0" FontSize="14" Foreground="Gray"></TextBlock>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,10,0,0">
<TextBlock Text="Previous Tasks - " FontSize="14" FontWeight="Bold" Foreground="Gray" Margin="0,0,5,0"></TextBlock>
<TextBlock Text="0" FontSize="14" Foreground="Gray"></TextBlock>
</StackPanel>
</StackPanel>
</StackPanel>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
And it creates something like this.
https://i.stack.imgur.com/0UmIx.png
I want to make only circles to be clickable not the text below that.
Is there any way to achieve that? Please guide me. Thanks in advance.
How to make only a part of gridview item clickable in uwp application?
For your requirement, you could set GridView IsItemClickEnabled property as false then listen Grid Tapped event like following.
<GridView IsItemClickEnabled="False" >
<GridView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<Grid Tapped="Grid_Tapped"
Width="30"
Height="30"
VerticalAlignment="Center"
Background="Red"
CornerRadius="15"
/>
<StackPanel VerticalAlignment="Center" Orientation="Vertical">
<TextBlock VerticalAlignment="Center" Text="NicoName" />
</StackPanel>
</StackPanel>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
private void Grid_Tapped(object sender, TappedRoutedEventArgs e)
{
}
Try this.
<GridView
Grid.Row="1"
Margin="130,40,130,40"
IsItemClickEnabled="False"
ScrollViewer.VerticalScrollBarVisibility="Hidden">
<GridView.ItemTemplate>
<DataTemplate>
<StackPanel Margin="50,25,50,25">
<Button
BorderBrush="Transparent"
BorderThickness="0"
Command="{Binding MyCommandName}"
Foreground="Transparent">
<Grid Width="120" Height="120">
<Image
Width="40"
Height="40"
Margin="80,0,0,80"
Canvas.ZIndex="99"
Source="assets/images/icons/check_my_blue.png" />
<Canvas>
<Ellipse
Width="120"
Height="120"
Fill="{x:Bind profile_color, FallbackValue='#00000'}"
Stroke="Black"
StrokeThickness="3" />
</Canvas>
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="28"
Foreground="White"
Text="{x:Bind profile_name}" />
</Grid>
</Button>
<StackPanel>
<StackPanel
Margin="0,10,0,0"
HorizontalAlignment="Center"
Orientation="Horizontal">
<TextBlock
FontSize="16"
FontWeight="Bold"
Text="{x:Bind first_name}" />
<TextBlock
FontSize="16"
FontWeight="Bold"
Text="{x:Bind last_name}" />
</StackPanel>
<StackPanel
Margin="0,10,0,0"
HorizontalAlignment="Center"
Orientation="Horizontal">
<TextBlock
Margin="0,0,5,0"
FontSize="14"
FontWeight="Bold"
Foreground="Gray"
Text="Today - " />
<TextBlock
FontSize="14"
Foreground="Gray"
Text="0" />
</StackPanel>
<StackPanel
Margin="0,10,0,0"
HorizontalAlignment="Center"
Orientation="Horizontal">
<TextBlock
Margin="0,0,5,0"
FontSize="14"
FontWeight="Bold"
Foreground="Gray"
Text="Previous Tasks - " />
<TextBlock
FontSize="14"
Foreground="Gray"
Text="0" />
</StackPanel>
</StackPanel>
</StackPanel>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
I have a listbox which is filled up with items taken from a data contract. I want to add a bit of xaml to the top of the listbox which takes data from another data contract. How do i go about doing this?
<phone:PivotItem>
<ScrollViewer>
<StackPanel>
<ListBox x:Name="StatusCommentsList"
Background="Transparent"
ItemsSource="{Binding StatusComments}"
u:ScrollViewerMonitor.AtEndCommand="{Binding FetchMoreStatusCommentsDataCommand}" VerticalContentAlignment="Top">
<!-- THIS DOESNT WORK-->
<ListBoxItem>
<Grid Height="auto">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="67" />
<ColumnDefinition Width="389"/>
</Grid.ColumnDefinitions>
<StackPanel Height="auto" Grid.Column="0" Background="Transparent">
<Border Background="Transparent" BorderThickness="0" Width="62" Height="62" HorizontalAlignment="Left" Margin="0,0,0,5">
<Image Source="{Binding Notification.context.data.created_by.image.thumbnail_link}" Width="62" Height="62"></Image>
</Border>
</StackPanel>
<StackPanel Height="auto" Grid.Column="1" Width="389" MaxWidth="389" Orientation="Vertical" >
<TextBlock TextWrapping="Wrap" Text="{Binding Notification.context.data.created_by.name}" HorizontalAlignment="Stretch" FontSize="30" VerticalAlignment="Center" Margin="0,0,0,5" Foreground="White" Width="389" MaxWidth="389" />
<TextBlock TextWrapping="Wrap" Text="{Binding Notification.context.data.created_on}" HorizontalAlignment="Stretch" FontSize="30" VerticalAlignment="Center" Margin="0,0,0,5" Foreground="White" Width="389" MaxWidth="389" />
<TextBlock TextWrapping="Wrap" Text="{Binding Notification.context.data.rich_value}" HorizontalAlignment="Stretch" FontSize="30" VerticalAlignment="Top" Margin="0,0,0,5" Foreground="White" Width="389" MaxWidth="389" />
</StackPanel>
</Grid>
</ListBoxItem>
<!-- /THIS DOESNT WORK -->
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel VerticalAlignment="Top" Margin="5,0,0,0">
<Button Style="{StaticResource JamesTransparentButton}" Padding="-5,0,-5,-5" Margin="-7,-12,-7,-7" Height="auto" BorderThickness="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" HorizontalContentAlignment="Left" UseLayoutRounding="True" FontSize="0.01">
<Grid Height="auto">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="67" />
<ColumnDefinition Width="389"/>
</Grid.ColumnDefinitions>
<StackPanel Height="auto" Grid.Column="0" Background="Transparent">
<Border Background="Transparent" BorderThickness="0" Width="62" Height="62" HorizontalAlignment="Left" Margin="0,0,0,5">
<Image Source="{Binding created_by.image.thumbnail_link}" Width="62" Height="62"></Image>
</Border>
</StackPanel>
<StackPanel Height="auto" Grid.Column="1" Width="389" MaxWidth="389" Orientation="Vertical" >
<TextBlock Text="{Binding created_by.name}" FontSize="30" VerticalAlignment="Top" Margin="0,0,0,5" Foreground="White" />
<TextBlock Text="{Binding created_on}" FontSize="30" VerticalAlignment="Top" Margin="0,0,0,5" Foreground="White" />
<TextBlock TextWrapping="Wrap" Text="{Binding value}" HorizontalAlignment="Stretch" FontSize="30" VerticalAlignment="Top" Margin="0,0,0,5" Foreground="White" Width="389" MaxWidth="389" />
</StackPanel>
</Grid>
</Button>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
</ScrollViewer>
</phone:PivotItem>
I tried just adding a new item to the listbox but the data contract would mean i have to instantiate all the sub levels of objects and it would suckkk as they are different domains.
Keep in mind that i want the entire screen to scroll in union... so that it looks like one big long list, regardless of the first being like a default value.
Put the first item outside the ListBox and disable ScrollViewer for the ListBox so the whole thing will scroll together. Here's an example where the item is a simple TextBlock. You can change it to suit your requirement.
<ScrollViewer>
<StackPanel Orientation="Vertical">
<TextBlock Text="Item 1"/>
<ListBox ScrollViewer.VerticalScrollBarVisibility="Disabled">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding item}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
</ScrollViewer>
I am developing an app where i need to show data from web service in a listbox. I am able to show data in my listbox but its not showing the complete data. There is some problem on managing the width of my box which i am not able to fix. Can anyone please help. Here is the code:
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<ScrollViewer Margin="0,17,0,49" VerticalScrollBarVisibility ="Visible" AllowDrop="False" ManipulationMode="Control">
<ListBox Name="listBox1" Margin="68,106,58,662">
<ListBox.ItemTemplate>
<DataTemplate>
<Button Width="300" Height="120">
<Button.Content>
<StackPanel Orientation="Horizontal" Height="80" Width="80" Margin="0,0,0,0">
<StackPanel Orientation="Vertical" Height="80">
<TextBlock Text="{Binding Path=News_Title}" TextWrapping="Wrap" ></TextBlock>
<TextBlock Text="{Binding Path=News_Description}" TextWrapping="Wrap"></TextBlock>
<TextBlock Text="{Binding Path=Date_Start}" TextWrapping="Wrap"></TextBlock>
</StackPanel>
</StackPanel>
</Button.Content>
</Button>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</ScrollViewer>
</Grid>
Everything is fine here, just few things were making the code messy, I have fixed them.
See the updated grid now :)
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<ListBox Name="listBox1">
<ListBox.ItemTemplate>
<DataTemplate>
<Button>
<Button.Content>
<ScrollViewer HorizontalScrollBarVisibility="Auto" Height="80" Width="400">
<StackPanel Orientation="Horizontal" Margin="0,0,0,0">
<StackPanel Orientation="Vertical" Height="80">
<TextBlock Text="{Binding Path=News_Title}" TextWrapping="Wrap" ></TextBlock>
<TextBlock Text="{Binding Path=News_Description}" TextWrapping="Wrap"></TextBlock>
<TextBlock Text="{Binding Path=Date_Start}" TextWrapping="Wrap"></TextBlock>
</StackPanel>
</StackPanel>
</ScrollViewer>
</Button.Content>
</Button>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
Check this, it would help :)
I am making an application in which I want to resize screen area when keyboard is open. Just like in this calendar application of windows phone.
After opening keyboard look screen should resize and also I should be able to scroll till the end of the page without closing keyboard:
In my application i am not able to do these things. In my page last elements of the page stays behind keyboard if i want to access that elements of the page i have to close keyboard but in calendar application of Nokia does great job by re sizing the page somehow so i can access whole part of page even though keyboard is open.
Can somebody help me out in this problem?
Here is code for my page
<!--TitlePanel contains the name of the application and page title-->
<StackPanel Grid.Row="0" Style="{StaticResource HeaderStackPanelStyle}">
<TextBlock TextAlignment="Center" Style="{StaticResource PhoneTextBlockHeaderStyle}" Text="Add Claim Item" />
</StackPanel>
<ScrollViewer Name="MainPageScroller" Grid.Row="1">
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Margin="12,0,12,12">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<StackPanel Name="MainContentPenal" Grid.Row="0">
<StackPanel >
<TextBlock TextAlignment="Left" Text="Category" Style="{StaticResource PhoneTextFirstItemStyle}" >
</TextBlock>
<ToolKit:ListPicker x:Name="CategoryListPicker"
ItemsSource="{Binding Categories}" SelectedItem="{Binding SelectedCategory, Mode=TwoWay}" SelectedIndex="{Binding Categories,Converter={StaticResource DefaultSetter}}"
ExpansionMode="FullScreenOnly" SelectionMode="Single" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" SelectionChanged="CategorySelection" ItemTemplate="{StaticResource CategoryTamplate}" FullModeItemTemplate="{ StaticResource CategoryTamplate}" >
</ToolKit:ListPicker>
</StackPanel >
<StackPanel Visibility="{Binding SelectedCategory, Converter={StaticResource TravelMileageHelper}, ConverterParameter=amount}" >
<TextBlock TextAlignment="Left" Text="Amount" Style="{StaticResource PhoneTextFirstItemStyle}" />
<TextBox x:Name="AmountTextBox" Style="{StaticResource WebExpensesTextBoxStyle}" Text="{Binding Amount, Mode=TwoWay}" KeyUp="numericTextBox_keyUp" KeyDown="numericTextBox_keyDown" InputScope="Number" TextChanged="TextChange_Event" />
</StackPanel>
<StackPanel Visibility="{Binding SelectedCategory, Converter={StaticResource TravelMileageHelper},ConverterParameter=mileage}" >
<TextBlock TextAlignment="Left" Text="Mileage units" Style="{StaticResource PhoneTextFirstItemStyle}" />
<TextBox x:Name="mileageTextBox" Text="{Binding MileageUnit, Mode=TwoWay}" Style="{StaticResource WebExpensesTextBoxStyle}" KeyUp="numericTextBox_keyUp" KeyDown="numericTextBox_keyDown" TextWrapping="Wrap" InputScope="Number" TextChanged="TextChange_Event"/>
</StackPanel>
<StackPanel Visibility="{Binding SelectedCategory, Converter={StaticResource TravelMileageHelper}, ConverterParameter=trip}" >
<TextBlock TextAlignment="Left" Text="Mileage" Style="{StaticResource PhoneTextFirstItemStyle}" />
<Button Content="Add mileage" Click="AddMileage"/>
</StackPanel>
<StackPanel Visibility="{Binding SelectedCategory,Converter={StaticResource TravelMileageHelper}, ConverterParameter=trip}" >
<StackPanel Visibility="{Binding TripMasterModel, Mode=TwoWay, Converter={StaticResource VisibiltyHelper}}">
<Grid DataContext="{Binding TripMasterModel}">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Row="0" Grid.Column="0">
<TextBlock TextWrapping="Wrap" HorizontalAlignment="Left" Margin="5 0 0 0" VerticalAlignment="Center" Text="{Binding Start}"></TextBlock>
</StackPanel>
<StackPanel Grid.Row="0" Grid.Column="1">
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Text="" FontFamily="Segoe UI Symbol" Style="{StaticResource PhoneTextNormalStyle}"/>
</StackPanel>
<StackPanel Grid.Row="0" Grid.Column="2">
<TextBlock TextWrapping="Wrap" VerticalAlignment="Center" Text="{Binding End}"></TextBlock>
</StackPanel>
<StackPanel Grid.Row="0" Grid.Column="3">
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Text="{Binding Distance}"/>
</StackPanel>
<StackPanel Visibility="{Binding subTrips,Converter={StaticResource VisibiltyHelper}}" Grid.Row="1" Orientation="Horizontal" Grid.ColumnSpan="4" >
<TextBlock HorizontalAlignment="Left" Text="via"/>
<ItemsControl ItemsSource="{Binding subTrips}" ItemTemplate="{StaticResource SubTripTemplate}" HorizontalAlignment="Left">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</StackPanel>
</Grid>
</StackPanel>
</StackPanel>
<StackPanel >
<TextBlock TextAlignment="Left" Text="Description" Style="{StaticResource PhoneTextFirstItemStyle}" />
<TextBox x:Name="DescriptionTextBox" Style="{StaticResource WebExpensesTextBoxStyle}" Text="{Binding Description, Mode=TwoWay}" Height="120" TextWrapping="Wrap" TextChanged="TextChange_Event" KeyDown="DescriptionTextBox_KeyDown"/>
</StackPanel>
<StackPanel >
<ToolKit:DatePicker HeaderTemplate="{StaticResource DatePickerHeader}" Value="{Binding SelectedDate,Mode=TwoWay}" ValueStringFormat="{Binding DateFormat}" HorizontalAlignment="Left" x:Name="DatePicker" VerticalAlignment="Top" Width="200" />
</StackPanel>
<StackPanel Visibility="{Binding Currencies, Converter={StaticResource VisibiltyHelper}}" >
<TextBlock TextAlignment="Left" Text="Currency" Style="{StaticResource PhoneTextFirstItemStyle}" />
<ToolKit:ListPicker x:Name="CurrencyListPicker"
ItemsSource="{Binding Currencies}" SelectedItem="{Binding SelectedCurrency, Mode=TwoWay}"
DisplayMemberPath="Name" SelectedIndex="{Binding Currencies,Converter={StaticResource DefaultSetter}}" FullModeItemTemplate="{ StaticResource CurrencyTamplate}" >
</ToolKit:ListPicker>
</StackPanel>
<StackPanel Visibility="{Binding Clients, Converter={StaticResource VisibiltyHelper}}" >
<TextBlock TextAlignment="Left" Text="Client" Style="{StaticResource PhoneTextFirstItemStyle}"/>
<ToolKit:ListPicker x:Name="ClientListPicker"
ItemsSource="{Binding Clients}" SelectedItem="{Binding SelectedClient, Mode=TwoWay}"
ItemTemplate="{StaticResource ShowMember}" SelectedIndex="{Binding Clients,Converter={StaticResource DefaultSetter}}" FullModeItemTemplate="{ StaticResource ClientTemplate}" >
</ToolKit:ListPicker>
</StackPanel>
<StackPanel Visibility="{Binding SubClients, Converter={StaticResource VisibiltyHelper}}" >
<TextBlock TextAlignment="Left" Text="Subclient" Style="{StaticResource PhoneTextFirstItemStyle}"/>
<ToolKit:ListPicker x:Name="SubClientListPicker"
ItemsSource="{Binding SubClients,Mode=TwoWay}"
DisplayMemberPath="Name" SelectedItem="{Binding SelectedSubclient, Mode=TwoWay}" SelectedIndex="{Binding SubClients,Converter={StaticResource DefaultSetter},Mode=TwoWay}" FullModeItemTemplate="{ StaticResource ClientTemplate}" >
</ToolKit:ListPicker>
</StackPanel>
<StackPanel Visibility="{Binding Vendors, Converter={StaticResource VisibiltyHelper}}" >
<TextBlock TextAlignment="Left" Text="Vendor" Style="{StaticResource PhoneTextFirstItemStyle}"/>
<ToolKit:ListPicker x:Name="VendorListPicker"
ItemsSource="{Binding Vendors}" SelectedItem="{Binding SelectedVendor, Mode=TwoWay}"
DisplayMemberPath="Name" SelectedIndex="{Binding Vendors,Converter={StaticResource DefaultSetter}}" SelectionChanged="vendorSelection" FullModeItemTemplate="{ StaticResource ClientTemplate}" >
</ToolKit:ListPicker>
</StackPanel>
<StackPanel >
<TextBlock TextAlignment="Left" Text="Receipt" Style="{StaticResource PhoneTextFirstItemStyle}"/>
<Button Click="AddReceipt_Btn_Click" Content="Add receipt"/>
</StackPanel>
<StackPanel x:Name="ImagePenal">
<ItemsControl Width="Auto" HorizontalAlignment="Stretch" ItemsSource="{Binding ReceiptList}" ItemTemplate="{StaticResource ImageListTemplate}" >
</ItemsControl>
</StackPanel>
</StackPanel>
</Grid>
</ScrollViewer>
Give your content in between ListBox or ScrollViewer.
<ListBox>
//your textbox and everything
</ListBox>
or
<ScrollViewer>
//your textbox and everything
</ScrollViewer>
I have been up and down looking on the internet and many people seem to have this problem but its generally solved by changing the container to a grid, constraining the height etc. etc. I can't to seem to get this to work.
I have an observableCollection thats feeding into a DataTemplate. I can't for th life of me get the scrollbar working. Its there but not enabling. Thanks Scott
<TabItem Header="select a call" x:Name="TabActiveCalls" Style="{DynamicResource MyTabItem}" FontFamily="QuickType">
<Grid Margin="0.125,0.412,3.125,0" Height="471" HorizontalAlignment="Stretch">
<StackPanel Orientation="Horizontal" Width="839.14" HorizontalAlignment="Left" VerticalAlignment="Top" Height="56">
<StackPanel Orientation="Vertical" HorizontalAlignment="Left" Margin="0,0,10,0" Width="741.14">
<StackPanel Height="28" Orientation="Horizontal" Width="733.14" HorizontalAlignment="Left">
<TextBlock x:Name="txtHistoryFound" TextWrapping="Wrap" Text="*" Foreground="#FFE20A0A" Visibility="Collapsed"/>
<TextBlock TextWrapping="Wrap" Text="filter by:" Margin="5,0,10,0" Foreground="#FF585AD4" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<TextBlock TextWrapping="Wrap" Text="call no" Margin="5,0,2,0" VerticalAlignment="Center" Foreground="#FF5E88DA"/>
<TextBox Template="{StaticResource TextBoxBaseControlTemplate}" x:Name="searchCallNo" TextChanged="searchCallNo_TextChanged" TextWrapping="Wrap" Width="67" Foreground="#FF1341B1" TextAlignment="Center" Margin="5,0,10,0" Height="22" VerticalAlignment="Center" />
<TextBlock TextWrapping="Wrap" Text="postcode" Margin="5,0,2,0" VerticalAlignment="Center" Foreground="#FF5E88DA"/>
<TextBox Template="{StaticResource TextBoxBaseControlTemplate}" x:Name="searchPostcode" TextWrapping="Wrap" Width="67" Foreground="#FF1341B1" TextAlignment="Center" Margin="5,0,10,0" Height="22" VerticalAlignment="Center"/>
<TextBlock Height="23" x:Name="txtSiteName" FontSize="16" Foreground="#FF0E7C0B" Width="409" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="0" TextAlignment="Right" Text="Airedale International Ltd" />
</StackPanel>
<StackPanel Width="733.14" HorizontalAlignment="Left">
<Border Height="21" Margin="5,6,8,0" CornerRadius="3,3,0,0" BorderThickness="1" BorderBrush="#FFC0BABA">
<StackPanel Orientation="Horizontal" Background="#FFD0D5DE">
<TextBlock TextWrapping="Wrap" Text="CALL NO. / DATE DUE/ CUSTOMER" Margin="5,0,0,0" Foreground="{DynamicResource ListTitle}" FontSize="10.667" VerticalAlignment="Center"/>
<TextBlock TextWrapping="Wrap" Text="ENGINEER / ADDRESS" Margin="114,0,0,0" Foreground="{DynamicResource ListTitle}" VerticalAlignment="Center"/>
<TextBlock TextWrapping="Wrap" Text="REPORT" Margin="43,0,0,0" Foreground="{DynamicResource ListTitle}" RenderTransformOrigin="2.543,0.429" VerticalAlignment="Center"/>
<TextBlock TextWrapping="Wrap" Text="CALL" Margin="28,0,0,0" Foreground="{DynamicResource ListTitle}" RenderTransformOrigin="2.543,0.429" VerticalAlignment="Center"/>
<TextBlock TextWrapping="Wrap" Text="POSITION" Margin="43,0,0,0" Foreground="{DynamicResource ListTitle}" RenderTransformOrigin="2.543,0.429" VerticalAlignment="Center"/>
</StackPanel>
</Border>
</StackPanel>
</StackPanel>
<Image Height="56" Width="90" Source="/ComfortReportEng;component/Media/Images/comfort_group.png"/>
</StackPanel>
<ListBox ItemTemplate="{StaticResource DataTemplateReportList}" ItemsSource="{Binding Source={StaticResource cvsReportList}}"
Margin="5,56,8,0" MaxHeight="415" Height="415" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.CanContentScroll="True"/>
</Grid>
</TabItem>
many thanks for getting back. Here is my DataTempate
<DataTemplate x:Key="DataTemplateReportList">
<Border Margin="0,2,0,0" BorderThickness="1" BorderBrush="#FFA19C9C" CornerRadius="3,3,0,0" Width="810.52" Height="50" >
<Grid Background="#FF737B89" Height="48" >
<StackPanel Orientation="Vertical" HorizontalAlignment="Left" Width="274" VerticalAlignment="Top" >
<StackPanel Height="23" Orientation="Horizontal" Margin="0">
<TextBlock TextWrapping="Wrap" Text="{Binding CallNo, Mode=TwoWay}" Foreground="#FF7DF51E" Margin="5,0,0,0" FontFamily="Verdana"/>
<TextBlock TextWrapping="Wrap" Text="{Binding DateDue, Mode=TwoWay, StringFormat=d}" Foreground="White" Margin="5,0,0,0" FontFamily="Verdana"/>
</StackPanel>
<StackPanel Height="23" Orientation="Horizontal">
<TextBlock TextWrapping="Wrap" Text="{Binding CompanyName, Mode=TwoWay}" Foreground="#FFFFEA00" Margin="5,0,0,0" FontFamily="Verdana"/>
</StackPanel>
</StackPanel>
<StackPanel HorizontalAlignment="Left" Width="456" Orientation="Vertical" Height="46" Margin="274,1,0,1" VerticalAlignment="Top">
<StackPanel Height="23" Orientation="Horizontal">
<TextBlock TextWrapping="Wrap" Text="{Binding EngineerName, Mode=TwoWay}" Foreground="#FFCAE5C6" Margin="5,0,0,0" FontFamily="Verdana" Width="140"/>
<TextBlock TextWrapping="Wrap" Text="{Binding ReportStatus, Mode=TwoWay}" Foreground="#FF7DF51E" Margin="20,0,0,0" FontFamily="Verdana" Width="50"/>
<TextBlock TextWrapping="Wrap" Text="{Binding CallStatus, Mode=TwoWay}" Foreground="#FF7DF51E" Margin="20,0,0,0" FontFamily="Verdana" Width="50"/>
<TextBlock TextWrapping="Wrap" Text="{Binding Position, Mode=TwoWay}" Foreground="White" Margin="20,0,0,0" FontFamily="Verdana" Width="50"/>
</StackPanel>
<StackPanel Height="23" Orientation="Horizontal">
<TextBlock TextWrapping="Wrap" Text="{Binding Address, Mode=TwoWay}" Foreground="#FFFFEA00" Margin="5,0,0,0" FontFamily="Verdana" Width="483.12"/>
</StackPanel>
</StackPanel>
<Grid Width="56" HorizontalAlignment="Right" Margin="0,0,12.52,0" VerticalAlignment="Top">
<Image Name="imgInfo" Source="/ComfortReportEng;component/Media/Images/Info4.png" Margin="24,8,0,0" Cursor="Hand" MouseLeftButtonDown="imgInfo_MouseLeftButtonDown"/>
</Grid>
</Grid>
</Border>
</DataTemplate>
Must be a bug. I have the following only..
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="ComfortReportEng.Views.EngineerReport.EngineerReport"
Title="Engineer Report" WindowStartupLocation="CenterScreen" Loaded="Window_Loaded" SizeToContent="WidthAndHeight" >
<Window.Resources>
<CollectionViewSource x:Key="cvsReportList"/>
</Window.Resources>
<Grid Margin="0.125,0.412,3.125,0" Height="471">
<ListBox Margin="23,64,3,0" Width="834.14" ItemsSource="{Binding Source={StaticResource cvsReportList}}"
x:Name="lbReportList" SelectionChanged="lbReportList_SelectionChanged" Background="#FFEEEFE4" />
</Grid>
and code is
private void LoadReportList()
{
int number = 0;
List<int> myNumbers = new List<int>();
while (number < 80)
{
myNumbers.Add(number);
number += 1;
}
_cvsReportList = (CollectionViewSource)(this.FindResource("cvsReportList"));
_cvsReportList.Source = myNumbers;
}
This was copied over from another project. Completely confused. Please don't worry. It's not a logical problem. Please take this as a close call with no solution. Cheers again Scott
Just to give this completeness. I am not sure why this happens but here is it.
if (System.Environment.MachineName == "SCOTT-PC")
{
this.txtUserName.Text = "Scott Fisher";
this.txtPassword.Password = "palace";
//LoginOK();
}
else
Keyboard.Focus(this.txtUserName);
If I clear the comments on LoginOK procedure I will get no scrollbar. With it commented and I interact with the login screen then everything is fine. Finally here is the code for the LoginOK.
if (LoginService.CheckLogin(txtUserName.Text, txtPassword.Password.ToString()))
{
Helpers.User.ThisUser = this.txtUserName.Text;
EngineerReport.EngineerReport engReport = new EngineerReport.EngineerReport()
{
Owner = Window.GetWindow(this),
WindowStartupLocation =
System.Windows.WindowStartupLocation.
CenterOwner
};
this.Hide();
engReport.ShowDialog();
}
else
{
this.txtPassword.Password = "";
this.txtPassword.Focus();
}
Can you provide you DataTemplate as I believe I have just managed to mock up what you are trying to achieve and I have scrollbars visible and working form the start.
Here is the xaml that I used for the DataTemplate for the ListBox:
<ListBox DataContext="{StaticResource MusicData}" ItemsSource="{Binding XPath=Album}">
<ListBox.ItemTemplate>
<DataTemplate>
<ListBoxItem>
<StackPanel Orientation="Horizontal" >
<TextBlock>No.</TextBlock>
<TextBlock Text="{Binding XPath=No}"></TextBlock>
<TextBlock>Title</TextBlock>
<TextBlock Text="{Binding XPath=Title}"></TextBlock>
</StackPanel>
</ListBoxItem>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Hope this helps.
I also found a piece of code I used a while back and this might help. You can try setting the ItemsPanelTemplate:
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel>
<ScrollViewer VerticalScrollBarVisibility="Visible" />
</StackPanel>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
This will work with any items control as stated in this article:
http://msdn.microsoft.com/en-us/library/system.windows.controls.itemscontrol.itemcontainerstyle.aspx
One final thing I can suggest is to create your own ControlTemplate for the ListBox Like so:
<ListBox.Template>
<ControlTemplate>
<ScrollViewer VerticalScrollBarVisibility="Auto">
<ItemsPresenter />
</ScrollViewer>
</ControlTemplate>
</ListBox.Template>