I'm using the XamDatagrid v14.2 and want to get a specific layout showing when the grid is loaded.
There are three fields being displayed in the grid: RowNumber, WebHeaderText, and WebText. I want to display the grid so the WebText column is showing right under WebHeaderText.
I was able to get it working by manually dragging the WebText column right below WebHeaderText. How do I do that programmatically so the WPF application starts up like that?
The before image below is currently how it looks when I load the WPF app. I'm trying to get the "After" layout programmatically.
Before:
After:
Here is the XAML code:
<window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:ViperWebUIAnnouncement" xmlns:custom="http://infragistics.com/DataPresenter" x:class="ViperWebUIAnnouncement.MainWindow" xmlns:igdp="http://infragistics.com/DataPresenter" mc:ignorable="d" title="Web Announcements">
<grid name="layoutRoot" horizontalalignment="Left">
<igdp:xamdatagrid name="xamDataGrid1" height="800" verticalalignment="Top">
<igdp:xamdatagrid.fieldlayoutsettings>
<igdp:fieldlayoutsettings autogeneratefields="False" allowaddnew="True" allowdelete="True" addnewrecordlocation="OnTop"></igdp:fieldlayoutsettings>
</igdp:xamdatagrid.fieldlayoutsettings>
<igdp:xamdatagrid.fieldlayouts>
<igdp:fieldlayout>
<igdp:fieldlayout.fields>
<igdp:field name="RowNumber" width="InitialAuto"></igdp:field>
<igdp:field name="WebHeaderText" width="InitialAuto"></igdp:field>
<igdp:field name="WebText" width="InitialAuto"></igdp:field>
</igdp:fieldlayout.fields>
</igdp:fieldlayout>
</igdp:xamdatagrid.fieldlayouts>
</igdp:xamdatagrid>
</grid>
</window>
Here is the C# code:
WebAnnouncementData webAnnouncementData;
public MainWindow()
{
InitializeComponent();
LoadData();
}
private void LoadData()
{
//XamDataGrid xamDataGrid1 = new XamDataGrid();
webAnnouncementData = new WebAnnouncementData(Environment.UserName);
BindingList<WebAnnouncement> webAnnoucementList = webAnnouncementData.GetWebAnnouncements();
xamDataGrid1.DataSource = webAnnoucementList;
}
I was able to get the layout I wanted in the grid by having WebHeaderText and WebText in the same column and on different rows.
Here is the code:
<igDP:Field Name="WebHeaderText" Width="InitialAuto" Row="0" Column="1"/>
<igDP:Field Name="WebText" Width="InitialAuto" Row="1" Column="1"/>
Related
Hi at the begining of this question i want to say that i'm beginer and thing i've done here could prolly be done better but i'm still learnig. i want to set a value of some variable that contains the actual width of grid, and whenever i resize my window obviously this width change and I don't know how to access it. What i want to do ? Just want my progress bar to scale up or down when resizing
Here is some code
<Window x:Class="Lista6.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Lista6"
mc:Ignorable="d"
Title="MainPage" Height="650" Width="1000"
Background="#36393F"
ResizeMode="CanResizeWithGrip"
Icon="/img/Ikonka2.png"
WindowStyle="None">
///other xaml code
<ProgressBar Foreground="White"
Value="50"
BorderThickness="0"
Background="Gray"
Height="5"
Width="{Binding Path=ProgresBarWidth[0], Mode=OneWay}"/>
</StackPanel>
</Grid>
</Grid>
</Window>
ObservableCollection<double> width = new ObservableCollection<double> { };
public ObservableCollection<double> ProgresBarWidth
{
get
{
return width;
}
set
{
width = value;
}
}
public AppOperator()
{
width.Add(0);
}
private void ProgresbarWidthSetter()
{
MainPage mp = new MainPage();
width[0] = mp.MusicBar.Width;
}
Here as u can see i ve binded progres bar width to ObservColl property, and i want to call it when im resizing my window but i ve no idea how to do that.
Thanks for any help and wish u all good.
I have ResourceDictionary that holds Dialog template. It has own DataType="{x:Type viewModels:DialogViewModel}". I would like to set this dialog "window" size on initialization. I know how to do it if I will add for example Height property to DialogViewModel. However this is not the right place to specify Height. How to do it in code behind and then Bind to that property? I think I have tried all the possible solutions I was able to find.
Basically I need to specify Height in SplitDialog.xaml.cs, let's say Height=500 and then add it to <Grid Margin="20,20,20,10" Tag="Category dialog" MinHeight="450" Height="???" x:Name="MainGrid">, but how?
I have tried to add to SplitDialog.xaml.cs (returns Height is null):
Grid gGrid = (Grid)this.FindName("MainGrid");
gGrid.Height = 600;
SplitDialog.xaml:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="Controls.Styles.Dialog.SplitDialog"
xmlns:viewModels="clr-namespace:ViewModels.Category;assembly=ViewModels">
<DataTemplate DataType="{x:Type viewModels:DialogViewModel}">
<DataTemplate.Resources>
<ResourceDictionary>
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
</ResourceDictionary>
</DataTemplate.Resources>
<Grid Margin="20,20,20,10" Tag="Category dialog" MinHeight="450" x:Name="MainGrid">
</Grid>
</DataTemplate>
</ResourceDictionary>
SplitDialog.xaml.cs:
public partial class SplitDialog : ResourceDictionary
{
public SplitDialog()
{
}
}
Provide this logic in Loaded event of the Grid, e.g:
<Grid Loaded="Grid_Loaded">...
then in code-behind:
private void Grid_Loaded(object sender, RoutedEventArgs e)
{
Grid grid = sender as Grid;
if (grid != null)
{
grid.Height = 600;
}
}
no?
I'm using Bing map WPF control SDK to try retrieving coordinates and printing them
I've managed to retrieve the coordinates of the center of the current LocationRect using an EventHandler associated with pressing the arrows
I've tried employing the same concept with mouse clicking event handlers but it didn't work, first I've registered the event using the += notation as follows:
public MainWindow()
{
InitializeComponent();
MainMap.Mode = new AerialMode(true);
MainMap.Focus();
MainMap.Culture = "ar-sa";
MainMap.MouseDoubleClick += new MouseButtonEventHandler(MapWithPushpins_MouseDoubleClick);
}
private void MapWithPushpins_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
e.Handled = true;
Point mousePosition = e.GetPosition(this);
Location pinLocation = MainMap.ViewportPointToLocation(mousePosition);
Pushpin pin = new Pushpin();
pin.Location = pinLocation;
Coordinates.Text = pinLocation.Longitude.ToString();
MainMap.Children.Add(pin);
}
And here's the XAML file:
<Window x:Class="Ornina.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:m="clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF"
xmlns:local="clr-namespace:Ornina"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<Grid VerticalAlignment="Top" >
<m:Map CredentialsProvider="AqCitpgSjIz_Sxd6AyI9Zm1rs1uRSG_G3Y7ebfok69ufB8W8uRdUtvheaRbz_10t" x:Name="MainMap" Center="36,38" ZoomLevel="16" Mode="AerialWithLabels" HorizontalAlignment="Center" VerticalAlignment="Top" Height="300" Width="500">
</m:Map>
</Grid>
<TextBlock x:Name="Coordinates">Coordinations</TextBlock>
</Grid>
</Window>
The program isn't responding with any thing, no exceptions, no errors
Your TextBlock is in front of your map, so the map doesn't receive the MouseDoubleClick event.
You can change the TextBlock to:
<TextBlock x:Name="Coordinates"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Text="Coordinations" />
So it's only in the top left corner and not in front of the whole map.
Or you can move it outside of the map entirely, in a different grid row or column.
I am trying to load a RenderWindowControl from vtk libraries on my WPF project using ActiViz.NET and Visual Studio 2013. The library works fine since I did a new project just to practice on it but when I try to integrate it into my work, the actor is not shown. This is my code:
MainWindow.xaml:
<Window x:Class="myProject.Views.MainWindow"
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:VtkTab="clr-namespace:myProject.Views.UITabs.VtkTab"
x:Name="Mainwindow"
MinHeight="600"
MinWidth="800"
Title="{Binding Title}"
Height="720"
Width="1280"
Icon="{StaticResource ApplicationIcon}"
Loaded="OnLoaded"
DataContext="{Binding Main, Source={StaticResource ViewModelLocator}}"
Style="{StaticResource WindowStyle}"
mc:Ignorable="d">
<DockPanel>
<TabControl>
....
....
<VtkTab:VtkTabView />
....
....
</TabControl>
</DockPanel>
</Window>
VtkTabView.xaml:
<UserControl x:Class="myProject.Views.UITabs.VtkTab.VtkTabView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vtk="clr-namespace:Kitware.VTK;assembly=Kitware.VTK"
Height="480" Width="640">
<WindowsFormsHost Name="Wfh">
<vtk:RenderWindowControl x:Name="RenderControl" />
</WindowsFormsHost>
</UserControl>
VtkTabView.xaml.cs:
public partial class UITabView
{
protected static Random _random = new Random();
vtkActor actor = vtkActor.New();
public VtkTabView()
{
InitializeComponent();
var sphere = vtkSphereSource.New();
sphere.SetThetaResolution(8);
sphere.SetPhiResolution(16);
var shrink = vtkShrinkPolyData.New();
shrink.SetInputConnection(sphere.GetOutputPort());
shrink.SetShrinkFactor(0.9);
var move = vtkTransform.New();
move.Translate(_random.NextDouble(), _random.NextDouble(), _random.NextDouble());
var moveFilter = vtkTransformPolyDataFilter.New();
moveFilter.SetTransform(move);
moveFilter.SetInputConnection(shrink.GetOutputPort());
var mapper = vtkPolyDataMapper.New();
mapper.SetInputConnection(moveFilter.GetOutputPort());
// The actor links the data pipeline to the rendering subsystem
actor.SetMapper(mapper);
actor.GetProperty().SetColor(1, 0, 0);
RenderControl.Load += RenderWindowControlOnLoad;
}
void RenderWindowControlOnLoad(object sender, EventArgs e)
{
var renderer = RenderControl.RenderWindow.GetRenderers().GetFirstRenderer();
renderer.AddActor(actor);
renderer.SetBackground(0, 1, 0);
renderer.Render();
}
}
As you can see, in the method RenderWindowControlOnLoad (VtkTabView.xaml.cs) I take the actor (a Sphere) and I add it to the render declared into the WPF but it is not displayed. I tried to change the background color and call to render just in case but it's still not working :(
Call
RenderControl.RenderWindow.Render();
instead of
renderer.Render();
I want to add a scroll viewer in a textBOX in a windows 8 app. So that user can scroll through his long text
Add a scrollviewer into the XAML. Then set the margins of the scrollviewer by cutting and pasting that of the textbox, and set the height and width of textbox to auto.
I just rewrote what Harshit explained and added some pics and Code.
Add a scrollviewer to your XAML
Select Margin in Scrollviewer (Best way: Click on the TestViewer-Code in the XAML to select it)
Set the Margin Values to Auto
Paste (in XAML) the Textbox and paste it in the Scrollviewer-Tag
Set the Height and width of Textbox to Auto
done!
XAML:
<Page
x:Class="testapp.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:newcalapp_winrt"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Margin="0,4,0,-4">
<Button Click="showText" Content="ShowText" x:Name="btn" Width="200" Height="56" Margin="1037,620,0,92"></Button>
<ScrollViewer x:Name="outputTextBoxScrollViewer" Margin="57,200,700,400">
<TextBox x:Name="outputTextBox" AcceptsReturn="True"/>
</ScrollViewer>
<ScrollViewer x:Name="outputTextBlockScrollViewer" Margin="57,450,700,169">
<TextBlock x:Name="outputTextBlock"/>
</ScrollViewer>
</Grid>
</Page>
C#:
namespace testapp
{
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
}
void showText(object sender, RoutedEventArgs args)
{
//OutputString
String outputString;
//Random number
Random randomizer = new Random();
int randomNumber = randomizer.Next(0,100000);
//Some magic with Dates :) Not important!
...
outputTextBox.Text = outputString;
outputTextBlock.Text = outputString;
}
}
}
http://i.stack.imgur.com/2qDyJ.png">