|
I havn't see this syntax before. I'v always seen bindings point to a property name.
Ok, so when you have
ItemSource="{Binding}"
then the list is bound to the entire class. Then it's up to the template to bind individual elements to properties on the class.
Do I have this right?
Everything makes sense in someone's mind
|
|
|
|
|
You don't generally do that on ItemsSource since it doesn't really make sense since ItemsSource has to point to a collection. If your VM itself is a collection then it will work. Generally you use it in a template, or maybe a parameter. Its basically for when you want to point to the entire object itself. So if your items source is List<Widget>,then in the data template, {Binding} will point to the entire Widget.
|
|
|
|
|
I understand. I did however get that example from a MS sample app.
Everything makes sense in someone's mind
|
|
|
|
|
Then the DataContext of the control points to something that implements IEnumerable.
|
|
|
|
|
The splitter move ok, but only the right area is resized. The list in the left area is not resized.
Anyone?
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<ListView Background="LightGreen"
Grid.Row="1"
Grid.Column="0" />
<GridSplitter Grid.Row="1"
Grid.Column="1"
VerticalAlignment="Stretch"
BackGround="SlateBlue"
Width="10"/>
<Border Grid.Row="1"
Grid.Column="2"
Background="LightBlue"/>
</Grid>
Everything makes sense in someone's mind
|
|
|
|
|
Remove the Width from the splitter; change the ColumnDefinitions as per below ...
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="10"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<ListView Background="LightGreen"
Grid.Row="1"
Grid.Column="0" />
<GridSplitter Grid.Row="1"
Grid.Column="1"
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch"
Background="SlateBlue" />
<Border Grid.Row="1"
Grid.Column="2"
Background="LightBlue" />
</Grid>
|
|
|
|
|
I've successfully bound two strings to a list, but am having trouble figuring out how to bind text with 2 radio buttons properly.
I have a zone array of 8 bytes, that holds On/Off values of the zone. There are 64 zones, thus the 8 bytes. So, bit 0 of byte 0 is '1', if the zone is ON, '0' if OFF.
I have limited space in a Grid, so I want to use a List or some other control that has automatic scrolling.
Something like:
Zone 1 ON<rb> OFF<rb>
Zone 2 ON<rb> OFF<rb>
.
.
Zone 63 ON<rb> OFF<rb>
Zone 64 ON<rb> OFF<rb>
I don't need any NotifyPropertyChanges, because when the user clicks on the SAVE button, the 8 bytes get resaved with the current settings.
I tried some things as I did before with string binding (see code), but this syntax isn't correct, and I don't know if I'm doing it correctly for Radio Buttons. Or maybe a list isn't the correct control.
List<ZoneEntry> zentry = new List<ZoneEntry>
public class ZoneEntry
{
public string ZoneNum { get; set; }
public RadioButton ZoneOff;
public RadioButton ZoneOn;
}
void CreateZoneTable()
{
for (byte i = 0; i < 64; i++)
{
zentry.Add(new ZoneEntry()
{
ZoneNum = "Zone " + (i + 1),
ZoneOff = ???
ZoneOn = ???
});
}
ZoneTable.ItemsSource = zentry;
}
<DataGrid Grid.Column="0" Grid.Row="1" Height="150" Width="300"
CanUserAddRows="false"
AutoGenerateColumns ="false"
HorizontalAlignment="Left"
RowHeight ="20"
Margin="15,10,0,0"
VerticalAlignment="Top"
Name="ZoneTable"
CanUserSortColumns="False"
CanUserResizeColumns="False"
CanUserReorderColumns="False"
CanUserResizeRows="False"
SelectionUnit="Cell">
<DataGrid.Columns>
<DataGridTextColumn Header = "Zone #"
Width = "SizeToHeader"
Binding = "{Binding ZoneNum}"
IsReadOnly="true"/>
<DataGridTextColumn Header = "Zone Setting"
Binding = "{Binding ZoneOn}"
Binding = "{Binding ZoneOff}"
Width="*"/>
</DataGrid.Columns>
</DataGrid>
What I want to do is set the RB to checked, if the proper zone[i] byte and bit is set to '1' when the table loads. When the user clicks SAVE, the values from zentry are converted back into the zone[i] array.
The WPF binding isn't right, because I don't know how to bind 2 RB under the same column.
Any help on the simplest approach or corrections/additions to the above?
Thanks.
Sutton
|
|
|
|
|
I'm making a model of human anatomy . there is about 2100 mesh and model. I used Helix 3d toolkit to import all files into a scene but that takes a long time to import (about 20 second) and scroll and rotations are slow. and that takes 800 meg of RAM.
objects are optimized and the sum of vertics must be less that 2 million.
i don't need shadows or any special effect. but i need scroll , zoom , hit testing and ..
what format should i use for saving models? i think .obj files are slow. should i use 3ds? or xaml?
should i use 2000 modelvisual3d or one with 2000 Geometrymodel3d ?
or should i use XNA?
can i disable some features to speed things up ?
tnx
|
|
|
|
|
Wow, you're really straining what WPF can cope with here. If I were you, I'd look to do this with XNA.
|
|
|
|
|
In a small Wpf application, use a DatePicker bound to a DateTime property.
When the user's region and language settings, and number and date format are German, the date is displayed in German, and the calendar shows German month names.
Now I wanted to get it in US-English. In the c'tor of MainWindow I added before InitializeComponent() (same situation when doing that after InitializeComponent() ):
string uiLanguage = ConfigurationManager.AppSettings["UILanguage"];
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(uiLanguage);
FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(uiLanguage)));
While that works with textboxes, it has no effect with the DatePicker.
Then I was cheaky and created a new user "John English", logged in as "John English", set his display language to English and the date and number format to US-English. Now the DatePicker always displays the date in the US-English format and the calendar shows English month names, even when I set the language of my program to German.
How can that be resolved? Can it be resolved at all?
|
|
|
|
|
|
Thanks for coming back and supplying the answer 5
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I have been working on styling an expander. When it's expanded, there is a line across the top that seperates the header area from the content area. Any way to remove this line?
I added this:
<Trigger Property="IsExpanded"
Value="True">
<Setter TargetName="Border"
Property="BorderThickness"
Value="0" />
</Trigger>
But it hide ALL of the header's border when the control is expanded. I just want to remove the lower portion of the header's border.
Thanks
Everything makes sense in someone's mind
|
|
|
|
|
Kevin Marois wrote: I just want to remove the lower portion of the header's border.
Then you can't use a border, you are going to have to break up the control so you can manipulate the lower bound!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: Then you can't use a border
Why not? You can set the thickness on each side individually.
|
|
|
|
|
Then you can use the border and you have answered the question! I have not played with the border other than the minimum, I responded based on the question, I would have thought the OP would have explored that before asking the question, it seems so obvious. Silly of me!
Have 5 sisnce the OP does not seem to have worked out the response to a good answer.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Set BorderThickness to "1,1,1,0" in your trigger.
|
|
|
|
|
Thank you. Thank you. Thank you.
You are a God!
Everything makes sense in someone's mind
|
|
|
|
|
Hi
I use a ComboBox style (the style from msdn example), but I customized it to replace the standard popup with a datagrid.
The problem I have is I can't catch Key.Down with the event handler PreviewKeyDown.
The comboBox is defined with the style described.
It has to do with the template style applied on the comboBox.
Somehow the keydown is caught by the combobox, because I see for few ms the ItemBinding path in the textBox, but it is not caught in the code.
I have tried also to put in style somthing like with no success.
<EventSetter Event="PreviewKeyDown" Handler="OnPreviewKeyDown" />
any ideas how to solve it?
Is it possible to use my comboBox declared in xaml and override OnPreviewKeyDown in the code behind?
<ComboBox Name="comboBoxFunctions"
Style="{DynamicResource ComboBoxStyleDataGridMethods}"
Height="23" HorizontalAlignment="Left" Margin="6,26,0,0"
IsEditable="true"
VerticalAlignment="Top" Width="231"
IsDropDownOpen="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Gui:BuildCommandWindow}}, Path=IsDropDownOpened }"
KeyUp="ComboBoxFunctionsKeyUp"
PreviewKeyUp="ComboBoxFunctionsPreviewKeyUp"
IsTextSearchEnabled="False" />
modified 27-Mar-12 11:54am.
|
|
|
|
|
I styled an expander control. I then templated a ListView so that each ListViewItem is the expander.
The problem is that the expander doesn't fill up to the width of the list. It only appears as wide as the expander's content.
Ok, here's the XAML. I know it's alot but I thought you may want to copy & paste to see what it does. Can anyone see why the list items don't sie properly?
<Window.Resources>
<!--Colors-->
<Color x:Key="Color1">Gray</Color>
<Color x:Key="Color2">SlateGray</Color>
<Color x:Key="Color3">DarkSlateGray</Color>
<Color x:Key="Color4">Orange</Color>
<Color x:Key="HeaderGradientBrush1">DarkGray</Color>
<Color x:Key="HeaderGradientBrush2">White</Color>
<!--Brushes-->
<SolidColorBrush x:Key="ToggleButtonEllipseBorderBrush"
Color="{StaticResource Color1}" />
<SolidColorBrush x:Key="ToggleButtonArrowBrush"
Color="{StaticResource Color2}" />
<SolidColorBrush x:Key="ToggleButtonUpArrowBrush"
Color="{StaticResource Color4}" />
<SolidColorBrush x:Key="ToggleButtonRectangleBrush"
Color="{StaticResource Color2}" />
<SolidColorBrush x:Key="ToggleButtonBackgroundBrush"
Color="Transparent" />
<SolidColorBrush x:Key="ContentAreaBackgroundBrush"
Color="White" />
<SolidColorBrush x:Key="ContentAreaBorderBrush"
Color="{StaticResource Color3}" />
<SolidColorBrush x:Key="CardSeperatorBorderBrush"
Color="{StaticResource Color3}" />
<SolidColorBrush x:Key="ExpanderBorderBrush"
Color="{StaticResource Color1}" />
<SolidColorBrush x:Key="ExpanderHeaderTextColor"
Color="{StaticResource Color3}" />
<LinearGradientBrush x:Key="headerGradientBrush"
EndPoint="0.504,1.5"
StartPoint="0.504,0.03">
<GradientStop Color="{StaticResource HeaderGradientBrush1}"
Offset="0" />
<GradientStop Color="{StaticResource HeaderGradientBrush2}"
Offset="0.567" />
</LinearGradientBrush>
<!--Control template for the Toggle Button-->
<ControlTemplate x:Key="ExpanderToggleButton"
TargetType="{x:Type ToggleButton}">
<Grid Width="16"
Height="16">
<Path x:Name="UpperArrow"
Stroke="{StaticResource ToggleButtonArrowBrush}"
StrokeThickness="2"
Data="M 3,4 l 5,5 5,-5" />
<Path x:Name="LowerArrow"
Stroke="{StaticResource ToggleButtonArrowBrush}"
StrokeThickness="2"
Data="M 3,9 l 5,5 5,-5" />
<ContentPresenter VerticalAlignment="Center"
HorizontalAlignment="Center"
Content="{TemplateBinding Content}" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked"
Value="true">
<Setter Property="Data"
TargetName="UpperArrow"
Value="M 3,9 l 5,-5 5,5" />
<Setter Property="Data"
TargetName="LowerArrow"
Value="M 3,6 l 5,-5 5,5" />
<Setter Property="Stroke"
TargetName="UpperArrow"
Value="{StaticResource ToggleButtonUpArrowBrush}" />
<Setter Property="Stroke"
TargetName="LowerArrow"
Value="{StaticResource ToggleButtonUpArrowBrush}" />
</Trigger>
<Trigger Property="IsMouseOver"
Value="true">
<Setter Property="Stroke"
TargetName="UpperArrow"
Value="{StaticResource ToggleButtonUpArrowBrush}" />
<Setter Property="Stroke"
TargetName="LowerArrow"
Value="{StaticResource ToggleButtonUpArrowBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<!-- Expander style -->
<Style x:Key="ContactCardExpanderStyle"
TargetType="Expander">
<Setter Property="Foreground"
Value="{StaticResource ExpanderHeaderTextColor}" />
<Setter Property="Template">
<Setter.Value>
<!-- Control template for Expander -->
<ControlTemplate TargetType="Expander">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Name="ContentRow"
Height="0" />
</Grid.RowDefinitions>
<!--Header Area-->
<Border Name="Border"
Grid.Row="0"
Background="{StaticResource headerGradientBrush}"
BorderBrush="{StaticResource ExpanderBorderBrush}"
BorderThickness="1">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="20" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="20" />
</Grid.ColumnDefinitions>
<!--Left Rectangle-->
<Rectangle x:Name="LeftPanel"
Grid.Row="0"
Fill="{StaticResource ExpanderBorderBrush}"
Width="10"
Margin="2"
HorizontalAlignment="Left" />
<!--Toggle Button-->
<ToggleButton Grid.Column="2"
IsChecked="{Binding Path=IsExpanded,Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
OverridesDefaultStyle="True"
Template="{StaticResource ExpanderToggleButton}"
Background="{StaticResource ToggleButtonBackgroundBrush}" />
<!--Caption-->
<ContentPresenter Grid.Column="1"
Margin="5"
ContentSource="Header"
RecognizesAccessKey="True" />
</Grid>
</Border>
<!--Content Area-->
<Border Name="Content"
Grid.Row="1"
Background="{StaticResource ContentAreaBackgroundBrush}"
BorderBrush="{StaticResource ExpanderBorderBrush}"
BorderThickness="1,0,1,1"
CornerRadius="0,0,3,3">
<ContentPresenter Margin="4" />
</Border>
</Grid>
<ControlTemplate.Triggers>
<!--This sets the foreground text to orange when the mouse is over
the control and the control is NOT expanded-->
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver"
Value="True" />
<Condition Property="IsExpanded"
Value="False" />
</MultiTrigger.Conditions>
<Setter Property="Foreground"
Value="{StaticResource ToggleButtonUpArrowBrush}" />
<Setter TargetName="LeftPanel"
Property="Fill"
Value="{StaticResource ToggleButtonUpArrowBrush}" />
</MultiTrigger>
<!--This sets the arrow and rectangle colors to orange when the mouse
is over the control and the control IS expanded-->
<Trigger Property="IsExpanded"
Value="True">
<Setter TargetName="ContentRow"
Property="Height"
Value="{Binding ElementName=Content,Path=DesiredHeight}" />
<Setter TargetName="Border"
Property="BorderBrush"
Value="{StaticResource ExpanderBorderBrush}" />
<Setter TargetName="LeftPanel"
Property="Fill"
Value="{StaticResource ToggleButtonUpArrowBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!--List Item Template-->
<DataTemplate x:Key="contactCardTemplate">
<Expander Style="{StaticResource ContactCardExpanderStyle}"
Header="{Binding DisplayName}"
Margin="2,2.5,2,2.5">
</Expander>
</DataTemplate>
</Window.Resources>
<Grid x:Name="LayoutRoot">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/> <!--Menu Row-->
<RowDefinition Height="Auto" /> <!--Toolbar Row-->
<RowDefinition Height="*" /> <!--Main Content Row-->
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" /> <!--Contacts Column-->
<ColumnDefinition Width="*" /> <!--Contact Info Column-->
<ColumnDefinition Width="*" /> <!--Right Panel Column-->
</Grid.ColumnDefinitions>
<!--Left side contacts list grid-->
<Grid x:Name="ContactsListGrid"
Grid.Row="2"
Grid.Column="0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <!--Options Expander Row-->
<RowDefinition Height="*" /> <!--Contacts List-->
</Grid.RowDefinitions>
<!--Contacts List-->
<ListView x:Name="ContactsList"
Grid.Row="1"
ItemsSource="{Binding Contacts}"
SelectedItem="{Binding SelectedContact, Mode=TwoWay}"
BorderBrush="{StaticResource ContentAreaBorderBrush}"
ItemTemplate="{StaticResource contactCardTemplate}"
Margin="3" />
</Grid>
</Grid>
Everything makes sense in someone's mind
|
|
|
|
|
Try
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
|
|
|
|
|
How would changing the height of the rows affect the width of the expanders in the list?
Everything makes sense in someone's mind
|
|
|
|
|
Hi, I am using WPF Toolkit Charting controls to create a bubble chart. I have been able to plot the bubble chart but now I need each bubble to be shown as a circle with sectors like in a piechart.
My first thought is to plot the piechart in a user control that would serve as a template for the bubble datapoints in the Bubble chart - if this is possible, i have no idea how to go about it.
So is there a way to customize the bubble Datapoints of the Bubble Series in this way or can someone tell me how i can achieve something like this.
Thanks in advance.
|
|
|
|
|
Did anyone knows the method to merge cells in C1Flexgrid for WPF not the usual DataGrid? I need to look my C1Flexgrid exactly like this,
Need to merge the cells and to give a back color to it. Please help me out.
|
|
|
|
|
You are posting a lot of questions here about a commercial third party control. When you purchased the control, you will also have purchased support for it - that would be the best place to start for getting expert help with the control. You might as well get your moneys worth.
|
|
|
|